Author Posts

January 1, 2012 at 12:00 am

by O.Ferre at 2012-12-17 02:21:38

Hi,
I try to write a script to shutdown computers from a list

example :
foreach($pc in $liste)
{
shutdown -s -m \\$pc -c "Shutdown -`n Shutdown" -f -t 100
}

But, sometimes, there is a blank line in the file $liste, so the local computer shutdown.
is there a way to continue if the line is blank
if ($pc -eq $null)
continue

thanks a lot
O.F

by MattG at 2012-12-17 04:35:06

You could simply check that the line is not null and shutdown accordingly:
foreach($pc in $liste)
{
if ($pc)
{
shutdown -s -m \\$pc -c "Shutdown -`n Shutdown" -f -t 100
}
}