1

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.

3
  • 2
    When you say you have used -Confirm, did you use it as -Confirm:$false? This is generally how the -Confirm parameter is used in order to prevent prompts, and I just want to confirm. Commented Jan 4, 2019 at 10:48
  • 3
    The other thing: Get-* cmdlets generally aren't causing change, so are you sure there isn't a different command prompting? You said you are using this command "in a loop to add multiple properties to my azure storage." Get-* cmdlets wouldn't be causing change, so I think you are looking at the wrong cause of your prompt. Should probably include an example of your code. Commented Jan 4, 2019 at 10:58
  • Hi achahbar, have you solved the issue? does the answer below work for you? Commented Jan 8, 2019 at 1:53

2 Answers 2

3

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.

enter image description here

Sign up to request clarification or add additional context in comments.

5 Comments

As this seems promising , saddly this doesn't work. I get this error powershell : Get-AzSKAzureServicesSecurityStatus : A positional parameter cannot be found that accepts argument 'check'powershell : Get-AzSKAzureServicesSecurityStatus : A positional parameter cannot be found that accepts argument 'check'
Can you post some dummy code so that I can test it at my side?
paste.ee/p/MAoRX This is a command from the module Azsk (import-module AzSK) Doc: github.com/azsk/DevOpsKit-docs
Hi @achahbar, where did you run the scripts? locally or somewhere?
i runned them on my locally
1

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!

1 Comment

Thnx for the effort. I think i am going to close this issue because indeed for security reasons this may not be even possible in Azsk. Your link however is already the way i am using to add bulk attestation statusses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.