progjm
asked on
powershell sleep time
i am new to powershell and hoping I can get some assistance. i am running this script to power down machines during a UPS power failure. How can I put in a sleeptime between each machine in the server.txt file. I have a particular order all machines need to power off
$psSwitches = ” -s -f -c -t 30?"
$strComputer = get-content “Servers.txt”
$application = “psshutdown.exe”
Foreach ($i in $strComputer)
{
$arguments = “\\$i” + $psSwitches + $psMessage
[System.Diagnostics.Proces s]::start( $applicati on,$argume nts)
# write-host $arguments
}
$psSwitches = ” -s -f -c -t 30?"
$strComputer = get-content “Servers.txt”
$application = “psshutdown.exe”
Foreach ($i in $strComputer)
{
$arguments = “\\$i” + $psSwitches + $psMessage
[System.Diagnostics.Proces
# write-host $arguments
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BTW, you do not need to use [System.Diagnostics.Proces s]::start for those calls. psshutdown (and almost all other external commands) can be run directly:
gc “Servers.txt” | % {
psshutdown \\$_ -s -f -c -t 30
start-sleep -s 10
}
ASKER
Sorry Qlemo saw your add after i accepted a solution, but thank you!
ASKER
I will give it a shot here in a bit