Software Development Kit (SDK) and API Discussions

Using update commands with queried objects

DerekC

It appears as if I have to do a lot of extra steps in order to use update commands with the powershell sdk.  For example, this is the detailed example for update-ncvol:

 

C:\PS>$q = Get-NcVol -Template
Initialize-NcObjectProperty $q VolumeIdAttributes
$q.VolumeIdAttributes.Name = "vol1|vol2"
$q.VolumeIdAttributes.OwningVserverName = "vserver1"
$a = Get-NcVol -Template
Initialize-NcObjectProperty $a VolumeIdAttributes
$a.VolumeIdAttributes.Comment = "Database volumes"
Update-NcVol -Query $q -Attributes $a

 

 

and it works when I try it out.  I am trying to gather and then update a set of volumes from a cluster by doing this:

 

$volumes = Get-NcVol

foreach ($vol in $volumes){
    $replaceWith = Get-NcVol -Template
    Initialize-NcObjectProperty $replaceWith VolumeIdAttributes 
    $replaceWith.VolumeIdAttributes.Comment = "test comment"

    Update-NcVol -Query $vol -Attributes $replaceWith
}

 

 

But it doesn't work.  Apparently I have no choice but to move information from the volumes I retrieved from the cluster to empty volumes in order to make it work?

 

 

 For instance, this works:

 

$volumes = Get-NcVol

foreach ($vol in $volumes){
   $query = Get-NcVol -Template
    Initialize-NcObjectProperty $query VolumeIdAttributes
    $query.Name = $vol.Name
    $query.Vserver = $vol.Vserver
 
    $replaceWith = Get-NcVol -Template
    Initialize-NcObjectProperty $replaceWith VolumeIdAttributes 
    $replaceWith.VolumeIdAttributes.Comment = "test comment"
 
    Update-NcVol -Query $query -Attributes $replaceWith
}

 

 

Is it necessary to do all these extra steps?  Wouldn't it make more sense if I could just use the queried vol object for the update command?  Please let me know if there's a better way.

 

Thanks

 

0 REPLIES 0
Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public