ONTAP Discussions

not able to bring the volume online.

Arjun_chris
2,442 Views

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

SeanLuce
2,370 Views

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

}

 

 

Arjun_chris
2,261 Views
Thanks Sean. You are right it needed a foreach loop.
Public