Reputation: 991
I know that this question seems familiar in a lot of stackoverflow questions. But This is not the same as the other questions. Basically i've got a PS script that uses the module "AzSK" to run something , I used this command in a loop to add multiple properties to my azure storage. On every step the command keeps asking me to confirm if i want to continue (Y/N). Because I use a loop for more than 40 iterations I need to confirm every time I perform the command. Like many Stackoverflow questions and the internet told me i need to try to add -Force , -Confirm to my command to automatically confirm the yes to the read input. But this answer only applies to commands that have this parameter build in. with the get-help command -Detailed I didn't see any of this parameter available. So I was wondering if it was possible to create this auto "Y" reply even if the command does not allow any parameter for it.
The command I use is Get-AzSKAzureServicesSecurityStatus
and this adds attestation statuses to control id inside a azure blob storage. the command only allows one attestation status to be added so I wrapped it inside a for loop. Which makes my struggle of constantly confirmation even worse.
Upvotes: 1
Views: 14075
Reputation: 61
This may not be an answer to your query "if it was possible to create this auto "Y" reply even if the command does not allow any parameter for it."
But since you are trying it specifically for the attestation feature of the Secure DevOps Kit for Azure(AzSK), this might help:
The reason the confirmation message pops up for each control and does not allow a "Forced" yes is because:
Utmost discretion is to be used when attesting controls using the Secure DevOps Kit for Azure(AzSK). In particular, when choosing to not fix a failing control, you are taking accountability that nothing will go wrong even though security is not correctly/fully configured.
Ideally, the bulk attestation feature is meant to be used in case the same control needs to be attested across multiple resource instances/resource groups and not vice versa. Refer this for scenarios where this feature can be used (although not recommended).
Hope this helps!
Upvotes: 1
Reputation: 29940
Please try to use the format below:
cmd /c echo y | powershell "the command which will propmt"
I did a simple test which to delete a directory, and works.
Upvotes: 3