Microsoft Virtualization Discussions
Microsoft Virtualization Discussions
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?
Solved! See The Solution
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
@tbernhardson a similar query discussed how to get around with issue in the below thread, see if that hepls
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