【发布时间】:2020-12-20 20:15:32
【问题描述】:
有没有办法绕过 Azure Automation Runbook 中 PowerShell cmdlet 的确认提示(是/否)。
使用 ECHO Y | powershell 在本地运行良好,但在 Azure 自动化中不行。
以下是错误
“PowerShell”一词未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。检查名称的拼写,如果包含路径,请验证路径是否正确,然后重试。
也尝试使用ECHO Y | pwsh。
任何建议或意见将不胜感激。
# Attestation
foreach ($inputItem in $inputContents) {
$ControlID = $inputItem.ControlID
$ResourceName = $inputItem.ResourceName
$AttestationStatus = $inputItem.AttestationStatus
$JustificationText = $inputItem.JustificationText
try {
echo Y | powershell Get-AzSKAzureServicesSecurityStatus -SubscriptionId $RunAsConnection.SubscriptionId `
-ResourceNames $ResourceName `
-ControlsToAttest NotAttested `
-ControlId $ControlID `
-AttestationStatus $AttestationStatus `
-JustificationText $JustificationText
Write-Host "INFO: Completed the attestation for $ResourceName"
}
catch {
Write-Host "ERROR: Could not attest the resource $ResourceName due to error $_ "
}
}
【问题讨论】:
标签: azure-automation