Microsoft Virtualization Discussions

Snapshot Comment not returned

tbernhardson

I'm writing a script that requires 3 attributes of a snapshot: Name, Created, and Comment. The problem I'm running into is twofold.

 

First, the Get-NcSnapshot command is not returning the Comment attribute of snapshots. According to the '-Attributes' parameter description: "If not specified, all data is returned for each object." However the Comment can only be retrieved when using the '-Attributes' parameter with an appropriate query template (e.g $query.Comment = $true). This would be fine except...

 

Second, when trying to set the query template to retrieve the Created field (e.g. $query.Created = $true) it returns an error:

'Created' is a ReadOnly property.
At line:1 char:1
+ $Query.Created = $true
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

 

I can retrieve all the information I need but it requires two calls to Get-NcSnapshot. The first to retrieve the bulk of the attributes, most of which I don't need, and an additional call just for the Comment.

 

Is there a way I can set the query template to retrieve the Created attribute? If not, can this be noted as a bug and fixed in the next release?

1 ACCEPTED SOLUTION

tbernhardson

Well, that explains why the Comment attribute isn't being returned. Unfortunately the Created attribute is still not accessible with the -Attributes parameter:

 

This works fine:

Get-NcVol | Get-NcSnapshot -Attributes @{ "name" = ""; "comment" = "" }  | select-object Name,Comment

But this:

Get-NcVol | Get-NcSnapshot -Attributes @{ "name" = ""; "comment" = ""; "created" = "" }  | select-object Name,Comment,Created

Returns:

Get-NcSnapshot : Cannot bind parameter 'Attributes'. Cannot create object of type
"DataONTAP.C.Types.Snapshot.SnapshotInfo". "AccessTimeDT" is a ReadOnly property.
At line:1 char:40
+ ...  -Attributes @{ "name" = ""; "comment" = ""; "created" = "" }  | sele ...
+                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-NcSnapshot], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,DataONTAP.C.PowerShell.SDK.Cmdlets.Snapshot.GetNcSnapshot

 

EDIT: I suppose it helps to read the entire thread you linked instead of just the Accepted Solution

 

This works fine:

Get-NcVol | Get-NcSnapshot -Attributes @{ "name" = ""; "comment" = ""; "accesstime" = "" }  | select-object Name,Comment,Created

View solution in original post

2 REPLIES 2

RajeshPanda

tbernhardson

Well, that explains why the Comment attribute isn't being returned. Unfortunately the Created attribute is still not accessible with the -Attributes parameter:

 

This works fine:

Get-NcVol | Get-NcSnapshot -Attributes @{ "name" = ""; "comment" = "" }  | select-object Name,Comment

But this:

Get-NcVol | Get-NcSnapshot -Attributes @{ "name" = ""; "comment" = ""; "created" = "" }  | select-object Name,Comment,Created

Returns:

Get-NcSnapshot : Cannot bind parameter 'Attributes'. Cannot create object of type
"DataONTAP.C.Types.Snapshot.SnapshotInfo". "AccessTimeDT" is a ReadOnly property.
At line:1 char:40
+ ...  -Attributes @{ "name" = ""; "comment" = ""; "created" = "" }  | sele ...
+                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-NcSnapshot], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,DataONTAP.C.PowerShell.SDK.Cmdlets.Snapshot.GetNcSnapshot

 

EDIT: I suppose it helps to read the entire thread you linked instead of just the Accepted Solution

 

This works fine:

Get-NcVol | Get-NcSnapshot -Attributes @{ "name" = ""; "comment" = ""; "accesstime" = "" }  | select-object Name,Comment,Created

View solution in original post

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