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
The
Test-Connection
is not installed in Azure Automation by default, so you could not use the cmdlet.You could import a module from the Automation Module Gallery with the Azure portal. More information please refer to this article.