Created
June 26, 2015 15:39
-
-
Save trstringer/51dd1ecb1847daeab324 to your computer and use it in GitHub Desktop.
Searches all file system drives for all Git repositories, and then lists them out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach ($DriveRoot in (Get-PSDrive | Where-Object {$_.Provider -like "*FileSystem"} | Select-Object -ExpandProperty Root)) { | |
Set-Location $DriveRoot | |
$FoundRepos = | |
Get-ChildItem ".git" -Directory -Force -Recurse -ErrorAction SilentlyContinue | | |
Select-Object @{Name = "Repository"; Expression = { $_.FullName.Substring(0, $_.FullName.IndexOf("\.git")) }} | |
if ($FoundRepos -eq $null) { | |
$RepoCount = 0 | |
} | |
elseif ($FoundRepos -ne $null -and $FoundRepos.Count -eq $null) { | |
$RepoCount = 1 | |
} | |
else { | |
$RepoCount = $FoundRepos.Count | |
} | |
"Found $RepoCount repository(ies) on $DriveRoot" | |
if ($RepoCount -gt 0) { | |
"========================" | |
$FoundRepos | | |
Select-Object -ExpandProperty Repository | |
} | |
"`r`n" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment