Public/Get-GitRepositories.ps1
function Get-GitRepositories { [CmdletBinding()] [OutputType([System.IO.DirectoryInfo[]])] Param( [Parameter(Mandatory = $false, Position = 0, ParameterSetName = "ParameterSetName", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Root path to scan sub folders.")][string[]]$Path = $pwd ) begin { [System.IO.DirectoryInfo[]]$result = @() } process { $childs = Get-ChildItem $Path -Directory foreach ($item in $childs) { Write-Debug "------ $($item.FullName) ----------" if ($item -is [System.IO.DirectoryInfo]) { $isGitFolder = Get-IsGitRepository $item if ($isGitFolder) { $result += $item } else { # check subfolders if ($item.Name -ne "node_modules") { $sub = Get-GitRepositories $item.FullName $result += $sub } } } } } end { return $result } } #get-GitRepositories C:\src\g-dotup | Select-Object {$_.FullName } | write-host # Test-GitFolder C:\src\g-dotup | Format-Table -Property Name, State, Commit, Push, Local, RemoteOrigin, FullName # c:\temp # git status |