Microsoft Virtualization Discussions

Set-NaVolOption

JSHACHER11
4,733 Views

hi Guys,

would this work:

+++++++++++++++++++

$vols = Get-Content c:\volumes.txt

Foreach ($vol in $vols)

{

Get-NaVol –Name $vol | Get-NaVolOption | ? {$_. fractional_reserve -ne 0} | Set-NaVolOption -Key fractional_reserve –Value 0

}

+++++++++++++++++

Thank you

1 ACCEPTED SOLUTION

JGPSHNTAP
4,733 Views

Your updated script will not work.

Change $volume to $vol

I didn't test it all but in theory it should work fine. 

View solution in original post

6 REPLIES 6

JGPSHNTAP
4,733 Views

That will not work.  Fractional_reserve is part of the name property.

Also, why are you dumping volumes from a file?  

I don't see you connecting to a controller either.. How you are planning on executing this,  That will determine how we can assist.

For example, what I would do

$hosts = gc c:\temp\filers.txt # list of filers

$hosts | % {

$Filer = $_

$c = connect-nacontroller $filer

$vols = Get-navol

$vols | % {

$volume = $_.name

if ((get-navoloption $volume | ? {$_.name -eq "fractional_reserve"}).value -ne 0)

{ set-navoloption $volume fractional_reserve 0

          }

     }

}

JSHACHER11
4,733 Views

"why are you dumping volumes from a file? " - I've been asked to do a list of volumes

"I don't see you connecting to a controller either" - I would have used the 'connect-nacontroller' obviously. I did not forget that

thanks for the rest of the script = I'll try that

Let me know if you want to add anything

thank you

JSHACHER11
4,733 Views

would this work?

++++++++++++++++++++++++++

$vols = Get-Content c:\volumes.txt

Foreach ($vol in $vols)

{

if ((get-navoloption $vol | ? {$_.name -eq "fractional_reserve"}).value -ne 0)

{ set-navoloption $volume fractional_reserve 0}

}

+++++++++++++++++++++++

JSHACHER11
4,733 Views

I would also like to save a report of what exactly was done - something like a combination of -Verbose and Start-Transcript

is that possible?

thank you

JGPSHNTAP
4,734 Views

Your updated script will not work.

Change $volume to $vol

I didn't test it all but in theory it should work fine. 

JSHACHER11
4,733 Views

it worked - thanks

Public