This would not be an alias (in PowerShell parlance), it would just be a function or a script.
Mostly you would just find the relevant analogues in PowerShell.
So ls in PowerShell is actually an alias for Get-ChildItem, which in PowerShell v3+ also supports a -Directory parameter to return only directories, so that part almost works right away.
Although you can do a foreach($thing in $things) loop, in this case it would be a bit more natural (PowerShell-ey) to pipe into ForEach-Object, so something like this:
$repos = 'C:\repos'
Get-ChildItem -Path $repos -Directory | ForEach-Object -Process {
Push-Location -Path $_
git pull
Pop-Location
}
For reference, using aliases and alternate syntax to make it look the most like your original, it could be done like this:
cd c:\repos
foreach ($dir in (ls -di)) {
git pull
cd ..
}
However I recommend the first one because:
- it preserves your original path
- it doesn't use aliases
- it uses what I feel is a more straightforward way of iterating (in PowerShell)
Neither of these examples handle the backgrounding of the task though. I left that out for the time being because it's not as analogous.
To do that you can use PowerShell Jobs. Either with Start-Job or with Invoke-Command -AsJob.
Have a look at how to use jobs and decide if you want to spend the time to apply it for just 10 repos though.
PS C:\> help about_Jobs