I'm trying to run the powershell script below in Micrososft Azure runbooks. However, I keep on getting the error:
The script is as follows:
#### Provide the computer name in $computername variable
$ServerName = "testauto","LocalHost","Server-2","Not-Exists", "Fake-computer", "Dc-1"
##### Script Starts Here ######
foreach ($Server in $ServerName) {
if (test-Connection -ComputerName $Server -Count 2 -Quiet ) {
write-Host "$Server is alive and Pinging " -ForegroundColor Green
} else
{ Write-Warning "$Server seems dead not pinging"
}
}
The script runs ok within Powershell ISE, but not in Microsoft Azure Automation Runbooks.
Can someone please let me know why?
Cheers
Carlton