ONTAP Discussions

Highlighted

not able to bring the volume online.

Hi All,

 

I am trying this code to bring the offline volumes to online state but i am seeing an error. Any help is much appriciated.

#Verify the volume state

$onlinevolumes = Get-NcVol

$onlinevolumes

if ($offlinevolumes = Get-NcVol |where {$_.State -ne "online"}) {

Write-Host "Volumes found which is/are not in online state, non online volumes are:$offlinevolumes"

$userresponse=Read-Host -Prompt "Press any to bring the volumes online"

Set-NcVol ($offlinevolumes |select Name) -Online }

 

Else {Read-Host -Prompt "No non online volumes found,press any key yo continue"}

-------------------------------------------------------------------------------------------------------------------

 

Here is the error:

 

Set-NcVol : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter
'Name'. Specified method is not supported.
At line:13 char:11
+ Set-NcVol ($offlinevolumes |select Name) -Online }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-NcVol], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,DataONTAP.C.PowerShell.SDK.Cmdlets.Volume.Set
NcVol

2 REPLIES 2
Highlighted

Re: not able to bring the volume online.

I think you will need to loop through each volume for the Set-NcVol command.  That command is expecting a single volume, I believe.  You also don't need '|select Name' as part of the command.

 

Something like...

 

foreach ($volume in $offlinevolumes) {

     Set-NcVol $volume -online

}

 

**EDIT**

 

You haven't defined $offlinevolumes before your if statement..

 

It should look something like this:

 

$offlinevolumes = Get-NcVol | where {$_state -ne "online"}

Write-Host "Volumes found which is/are not in online state, non online volumes are:$offlinevolumes"

$userresponse=Read-Host -Prompt "Press any to bring the volumes online"

foreach ($volume in $offlinevolumes) {

     Set-NcVol $volume -Online

}

 

 

Highlighted

Re: not able to bring the volume online.

Thanks Sean. You are right it needed a foreach loop.
Check out the KB!
NetApp Insights To Action
All Community Forums