Automatically confirm Yes to powershell script
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
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.
azure powershell
add a comment |
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.
azure powershell
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.
– ScriptAutomate
Jan 4 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.
– ScriptAutomate
Jan 4 at 10:58
Hi achahbar, have you solved the issue? does the answer below work for you?
– Ivan Yang
Jan 8 at 1:53
add a comment |
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.
azure powershell
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.
azure powershell
azure powershell
asked Jan 4 at 8:57
achahbarachahbar
209116
209116
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.
– ScriptAutomate
Jan 4 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.
– ScriptAutomate
Jan 4 at 10:58
Hi achahbar, have you solved the issue? does the answer below work for you?
– Ivan Yang
Jan 8 at 1:53
add a comment |
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.
– ScriptAutomate
Jan 4 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.
– ScriptAutomate
Jan 4 at 10:58
Hi achahbar, have you solved the issue? does the answer below work for you?
– Ivan Yang
Jan 8 at 1:53
2
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.– ScriptAutomate
Jan 4 at 10:48
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.– ScriptAutomate
Jan 4 at 10:48
3
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.
– ScriptAutomate
Jan 4 at 10:58
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.
– ScriptAutomate
Jan 4 at 10:58
Hi achahbar, have you solved the issue? does the answer below work for you?
– Ivan Yang
Jan 8 at 1:53
Hi achahbar, have you solved the issue? does the answer below work for you?
– Ivan Yang
Jan 8 at 1:53
add a comment |
2 Answers
2
active
oldest
votes
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!
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.
– achahbar
Jan 25 at 14:21
add a comment |
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.
As this seems promising , saddly this doesn't work. I get this errorpowershell : 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'
– achahbar
Jan 8 at 8:42
Can you post some dummy code so that I can test it at my side?
– Ivan Yang
Jan 8 at 8:44
paste.ee/p/MAoRX This is a command from the module Azsk (import-module AzSK) Doc: github.com/azsk/DevOpsKit-docs
– achahbar
Jan 8 at 8:49
Hi @achahbar, where did you run the scripts? locally or somewhere?
– Ivan Yang
Jan 8 at 10:01
i runned them on my locally
– achahbar
Jan 18 at 7:51
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54035744%2fautomatically-confirm-yes-to-powershell-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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!
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.
– achahbar
Jan 25 at 14:21
add a comment |
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!
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.
– achahbar
Jan 25 at 14:21
add a comment |
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!
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!
answered Jan 25 at 14:04
Khushboo-msftKhushboo-msft
612
612
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.
– achahbar
Jan 25 at 14:21
add a 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.
– achahbar
Jan 25 at 14:21
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.
– achahbar
Jan 25 at 14:21
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.
– achahbar
Jan 25 at 14:21
add a comment |
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.
As this seems promising , saddly this doesn't work. I get this errorpowershell : 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'
– achahbar
Jan 8 at 8:42
Can you post some dummy code so that I can test it at my side?
– Ivan Yang
Jan 8 at 8:44
paste.ee/p/MAoRX This is a command from the module Azsk (import-module AzSK) Doc: github.com/azsk/DevOpsKit-docs
– achahbar
Jan 8 at 8:49
Hi @achahbar, where did you run the scripts? locally or somewhere?
– Ivan Yang
Jan 8 at 10:01
i runned them on my locally
– achahbar
Jan 18 at 7:51
add a comment |
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.
As this seems promising , saddly this doesn't work. I get this errorpowershell : 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'
– achahbar
Jan 8 at 8:42
Can you post some dummy code so that I can test it at my side?
– Ivan Yang
Jan 8 at 8:44
paste.ee/p/MAoRX This is a command from the module Azsk (import-module AzSK) Doc: github.com/azsk/DevOpsKit-docs
– achahbar
Jan 8 at 8:49
Hi @achahbar, where did you run the scripts? locally or somewhere?
– Ivan Yang
Jan 8 at 10:01
i runned them on my locally
– achahbar
Jan 18 at 7:51
add a comment |
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.
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.
answered Jan 4 at 9:42
Ivan YangIvan Yang
4,497128
4,497128
As this seems promising , saddly this doesn't work. I get this errorpowershell : 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'
– achahbar
Jan 8 at 8:42
Can you post some dummy code so that I can test it at my side?
– Ivan Yang
Jan 8 at 8:44
paste.ee/p/MAoRX This is a command from the module Azsk (import-module AzSK) Doc: github.com/azsk/DevOpsKit-docs
– achahbar
Jan 8 at 8:49
Hi @achahbar, where did you run the scripts? locally or somewhere?
– Ivan Yang
Jan 8 at 10:01
i runned them on my locally
– achahbar
Jan 18 at 7:51
add a comment |
As this seems promising , saddly this doesn't work. I get this errorpowershell : 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'
– achahbar
Jan 8 at 8:42
Can you post some dummy code so that I can test it at my side?
– Ivan Yang
Jan 8 at 8:44
paste.ee/p/MAoRX This is a command from the module Azsk (import-module AzSK) Doc: github.com/azsk/DevOpsKit-docs
– achahbar
Jan 8 at 8:49
Hi @achahbar, where did you run the scripts? locally or somewhere?
– Ivan Yang
Jan 8 at 10:01
i runned them on my locally
– achahbar
Jan 18 at 7:51
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'
– achahbar
Jan 8 at 8:42
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'
– achahbar
Jan 8 at 8:42
Can you post some dummy code so that I can test it at my side?
– Ivan Yang
Jan 8 at 8:44
Can you post some dummy code so that I can test it at my side?
– Ivan Yang
Jan 8 at 8:44
paste.ee/p/MAoRX This is a command from the module Azsk (import-module AzSK) Doc: github.com/azsk/DevOpsKit-docs
– achahbar
Jan 8 at 8:49
paste.ee/p/MAoRX This is a command from the module Azsk (import-module AzSK) Doc: github.com/azsk/DevOpsKit-docs
– achahbar
Jan 8 at 8:49
Hi @achahbar, where did you run the scripts? locally or somewhere?
– Ivan Yang
Jan 8 at 10:01
Hi @achahbar, where did you run the scripts? locally or somewhere?
– Ivan Yang
Jan 8 at 10:01
i runned them on my locally
– achahbar
Jan 18 at 7:51
i runned them on my locally
– achahbar
Jan 18 at 7:51
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54035744%2fautomatically-confirm-yes-to-powershell-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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.– ScriptAutomate
Jan 4 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.
– ScriptAutomate
Jan 4 at 10:58
Hi achahbar, have you solved the issue? does the answer below work for you?
– Ivan Yang
Jan 8 at 1:53