NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform. You will still be able to view content, but posting and replying will be temporarily disabled.
We're excited to launch our new Community experience on July 30 and more information will follow soon.
Stay connected during the transition - Join our Discord community today.

ONTAP Discussions

not able to bring the volume online.

Arjun_chris
3,596 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
3,524 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
3,415 Views
Thanks Sean. You are right it needed a foreach loop.
Public