Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Error poweshell script (else command)

$
0
0

Hi 

I'm trying to make a script to run multiple commands depending on whether the equipment is online or not, but I get an error in the "else". 

Any idea?

$path = “E:\Inventory\”
$serverlist = get-content “$path\servers.txt”
foreach ($server in $serverlist){
 $result = Test-Connection $server -Count 1 -Quiet
 if ($result -eq “True”){
{.\psexec.exe \\$server -S gpupdate.exe /target:computer /force}
Start-Sleep -Seconds 5
}
 }
else
 {
 Add-Content “$path\noping.txt” -Value $server
 }


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>