我试图在Micrososft Azure Runbook中运行下面的powershell脚本。 但是,我不断收到错误:
脚本如下:
#### 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" } }
该脚本在Powershell ISE中运行正常,但不在Microsoft Azure自动化Runbook中运行。
有人可以让我知道为什么吗?
干杯
卡尔顿
Test-Connection默认情况下未安装在Azure自动化中,因此您无法使用该cmdlet。
您可以使用Azure门户从自动化模块库导入模块。 更多信息请参考这篇文章 。