Microsoft Virtualization Discussions

remove-navol help

corey

Hi,

In my script I want to remove a list of volumes, and I want to do so without it prompting me with the "Are you sure you want to destroy..." message.

Here's the section of the script I am referring to:

foreach ($VOL in $vol_list)
{
Set-NaVol $VOL -offline | Remove-NaVol
}

However when I run this it prompts with the "Are you sure you want to destroy volume ..." and you need to answer "Y" or hit enter to continue, and again for every volume in the list.  How can I force this to just happen without user intervention?

Thanks,
Corey

4 REPLIES 4

Re: remove-navol help

egrigson1

You can simply append -Confirm:$false to your Remove-NaVol command like so;

Set-NaVol $VOL -offline | Remove-NaVol -Confirm:$False

Obviously you want to be careful once that's in place as you won't get a second chance. You can test what would happen by using -WhatIf like so;

Set-NaVol $VOL -offline | Remove-NaVol -Confirm:$False -Whatif

Regards,

Ed.

View solution in original post

Re: remove-navol help

corey

Fantastic!  That worked a charm.

Thanks heaps Ed

I do understand the dangers of this, but it is handy to know.

Cheers.

Re: remove-navol help

v_ovesny

Hi,

Whe I use

Set-NaVol $VOL -offline | Remove-NaVol -Confirm:$False -Whatif

before:

Temper                online    80,0 GB0%80,0 GB  True     103     3M aggr3

after:

Temper                offline         00%      0 False       0      0 aggr3

Volume is not removed, only Offline state and information is 0.

When I use without -Confirm:$False -Whatif, VOL is removed OK.

Any Idea ?

Re: remove-navol help

JGPSHNTAP

^^

Confused.. Do you know what -whatif does?

The command doesn't execute if you specify -whatif

The command should work fine with - Remove-NaVol -Confirm:$False

Earn Rewards for Your Review!
GPI Review Banner
All Community Forums
Public