Microsoft Virtualization Discussions

-NoPrompt or -Force for a few commands

jurphville

The following commands require that a user confirm the operation before continuing...

Invoke-NaSnapmirrorRelease

Invoke-NaSnapmirrorBreak

Remove-NaSnapshot

I would like to be able to answer "yes" programmatically for these commands so the user is not prompted for each item.  Is that possible?

I see that each of these cmdlets have a -Confirm switch, but they seem to behave the same weather the switch is set or not.

3 REPLIES 3

jausch

Yes, the simplest way to do this is to use the $confirmpreference environment variable.  To turn off prompts completely, add the following to the top of your script:

$confirmpreference = "none"

Alex

cknight

You can also disable prompts on a per-cmdlet basis by specifying -Confirm:$false.

jurphville

Thanks for the great suggestions.  I tried using -Confirm $false, but that didn't work...I was missing the colon syntax, -Confirm:$false works great.

I'm curious why that option defaults to $true?  I understand the reasoning from an administrative perspective...those are dangerous commands.  From from a programming perspective, if the default is $true, maybe there should be -NoConfirm switch to change it to false?

Thanks again for the help!

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public