I am trying to write a script in PowerShell to backup our collection of Mercurial repositories.
I started with this:
$repos=Get-ChildItem C:\hgrepos|Where-Object { $_.PSIsContainer }
This will get the first level of folders under C:\hgrepos, which normally would be fine, as this is where our repositories are located. However, subrepositories exist. So I need to go recursive. And most importantly, only folders containing a .hg subfolder should be listed.
You can use the
-recurseflag inGet-ChildItemIt will be something like this: