问题描述
是否可以绕过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 $_ "
}
}