有没有一种方法可以绕过Azure Automation Runbook中的Power-Shell确认Y / N提示

问题描述

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

}

解决方法

通常,您可以按照here中所述的各种方式绕过确认。如果您在Runbook试图完成的事情上共享更多的上下文,则可以推荐最简单,最安全的方法。

更新2 : 感谢您提供有关此问题的其他背景信息。由于问题与AzSK有关,默认情况下不接受上述-Confirm / -Force等问题,因此我向AzSK的维护者提出了this功能请求。请检查它以备将来更新。

此外,请检查khushboo在this问题中的回答,该问题解释了有关问题。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...