I am still very new to PowerShell and need some help.
I have some .bat files in a folder called: c:\scripts\run\
and I want to run them one by one but I don't know how many I have, it changes from time to time.
So I want to run a loop with foreach
like this:
foreach ($file in get-childitem c:\scripts\run | where {$_.extension -eq ".bat"})
But I don't know how to run them now. I know that I can run them 1 by 1 like this :
./run1.bat
./run2.bat
./run3.bat
But how do I implement that? Thanks!!
Try this:
Get-Childitem -Path c:\scripts\run -Filter *.bat | % {& $_.FullName}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With