Is there a way to bypass the PowerShell cmdlet's confirmation prompt (Yes/No) in Azure Automation Runbook.
Using ECHO Y | powershell
worked fine locally, but not in Azure Automation.
Below is the error
The term 'PowerShell' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Tried with the ECHO Y | pwsh
as well.
Any suggestions or advice will be appreciated.
# 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 $_ "
}
}