Created
May 29, 2024 22:22
-
-
Save franklindyer/970be067c20fd56c1b8fd09dbf25e3ae to your computer and use it in GitHub Desktop.
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
# USAGE: .\multidir.ps1 --dirs "directory1,...,directoryn" | |
# Execute a sequence of commands sequentially in each of the directories | |
param ( | |
[string]$dirs = "" | |
) | |
$dirlist = $dirs.Split(",") | |
While (($cmd = Read-Host -Prompt "multidir> ") -ne "exit") { | |
ForEach ($dir in $dirlist) { | |
pushd $dir | |
Invoke-Expression $cmd | |
popd | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment