When you’re building PowerShell tools for your
Enterprise using the Data ONTAP PowerShell Toolkit, it’s important to understand the use of Initialize-NcObjectProperty and -Template. Together, these allow you to limit the amount of data pulled from
your Cluster, and this can massively speed up your scripts, as well as save processing
load on the Cluster Nodes. Without using -Template you pull all the information
that Get-Nc* command can grab. And the best example is Get-NcVol.
It’s always easiest to demonstrate things with an
example, so here’s an example using -Template to gather minimal attributes, and query for just "rw" volumes.
$Attributes
= Get-NcVol -Template
$Query
= Get-NcVol -Template
Initialize-NcObjectProperty
-object $Query -name VolumeIdAttributes
$Query.VolumeIdAttributes.Type
= "rw"
$RWvolumes
= Get-NcVol -Attributes $Attributes -Query $Query
To understand where to use Initialize-NcObjectProperty, a very useful script is Display-All.ps1.
Basically, anything with two dots "..", if you want to obtain that
information as an attribute or use it for a query, whatever’s the dot "."
above you must initialize. Below is an example of using Display-All for a
Get-NcVol request (as you see, a simple Get-NcVol for just one volume brings
back and a lot of info):
PS
C:\> display-all (get-ncvol -Name cvol001) -all
.Name = cvol001
.Volume64bitUpgradeAttributes =
.VolumeAntivirusAttributes
..OnAccessPolicy = default
.VolumeAutobalanceAttributes =
.VolumeAutosizeAttributes
..GrowThresholdPercent = 85
..IncrementPercent =
..IncrementSize = 107372544
..IsEnabled = False
..MaximumSize = 2576977920
..MinimumSize = 2147483648
..Mode = off
..Reset =
..ShrinkThresholdPercent = 50
.VolumeCloneAttributes =
.VolumeDirectoryAttributes
..I2pEnabled = True
..IndexDirEnabled =
..MaxDirSize = 16723968
..RootDirGen = 7802560
.VolumeExportAttributes
..Policy = TEST
.VolumeFlexcacheAttributes =
.VolumeHybridCacheAttributes
..CachingPolicy =
..Eligibility = read_write
..WriteCacheIneligibilityReaso
=
.VolumeIdAttributes
..Comment =
..ConstituentRole =
..ContainingAggregateName = aggr1
..ContainingAggregateUuid = aff39dba-eef6-4e8e-b3e3-86657a55b8d6
..CreationTime = 1428069446
..CreationTimeDT = 04/03/2015 14:57:26
..Dsid = 1026
..Fsid = 1026
..InstanceUuid =
8256b65f-ce2e-4665-847c-72cbee62895a
..JunctionParentName =
..JunctionPath =
..Msid = 2147484674
..Name = cvol001
..NameOrdinal = base
..Node =
..ProvenanceUuid =
8256b65f-ce2e-4665-847c-72cbee62895a
..Style = flex
..Type = rw
..Uuid =
5c2628eb-da09-11e4-b88a-123478563412
.VolumeInfinitevolAttributes =
.VolumeInodeAttributes
..BlockType = 64_bit
..FilesPrivateUsed = 509
..FilesTotal = 62244
..FilesUsed = 116
..InodefilePrivateCapacity = 31142
..InodefilePublicCapacity =
31142
.VolumeLanguageAttributes
..IsConvertUcodeEnabled = True
..IsCreateUcodeEnabled = True
..Language = en (English)
..LanguageCode = en
..NfsCharacterSet = iso-8859-1|iso-8859-1|Thu
Oct 1 22:00:53 GMT 1998
..OemCharacterSet = cp850|cp850|Thu Oct 1 22:00:53 GMT 1998
.VolumeMirrorAttributes
..IsDataProtectionMirror = False
..IsLoadSharingMirror = False
..IsMoveMirror = False
..IsReplicaVolume = False
..MirrorTransferInProgress = False
..RedirectSnapshotId = 0
.VolumePerformanceAttributes
..ExtentEnabled = off
..FcDelegsEnabled = True
..IsAtimeUpdateEnabled = True
..MaxWriteAllocBlocks = 0
..MinimalReadAhead = False
..ReadRealloc = off
.VolumeQosAttributes =
.VolumeSecurityAttributes
..Style = ntfs
..VolumeSecurityUnixAttributes
...GroupId =
...Permissions = 0
...UserId =
.VolumeSisAttributes
..CompressionSpaceSaved = 0
..DeduplicationSpaceSaved = 0
..DeduplicationSpaceShared = 0
..IsSisLoggingEnabled = False
..IsSisVolume = False
..PercentageCompressionSpaceSa
= 0
..PercentageDeduplicationSpace
= 0
..PercentageTotalSpaceSaved = 0
..TotalSpaceSaved = 0
.VolumeSnapshotAttributes
..AutoSnapshotsEnabled = True
..SnapdirAccessEnabled = True
..SnapshotCloneDependencyEnabl
= False
..SnapshotCount = 18
..SnapshotPolicy = 1M_2W_13N_23H
.VolumeSnapshotAutodeleteAttributes
..Commitment = try
..DeferDelete = user_created
..DeleteOrder = oldest_first
..DestroyList = none
..IsAutodeleteEnabled = False
..Prefix = (not specified)
..TargetFreeSpace = 20
..Trigger = volume
.VolumeSpaceAttributes
..FilesystemSize = 2147483648
..IsFilesysSizeFixed = False
..IsSpaceGuaranteeEnabled = True
..OverwriteReserve = 0
..OverwriteReserveRequired = 0
..OverwriteReserveUsed = 0
..OverwriteReserveUsedActual = 0
..PercentageFractionalReserve = 0
..PercentageSizeUsed = 5
..PercentageSnapshotReserve = 5
..PercentageSnapshotReserveUse
= 2
..PhysicalUsed =
..PhysicalUsedPercent =
..Size = 2147483648
..SizeAvailable = 2039791616
..SizeAvailableForSnapshots = 2145214464
..SizeTotal = 2040111104
..SizeUsed = 319488
..SizeUsedBySnapshots = 1949696
..SnapshotReserveSize = 107372544
..SpaceFullThresholdPercent = 98
..SpaceGuarantee = none
..SpaceMgmtOptionTryFirst = volume_grow
..SpaceNearlyFullThresholdPerc
= 95
.VolumeStateAttributes
..BecomeNodeRootAfterReboot = False
..ForceNvfailOnDr =
..IgnoreInconsistent = False
..InNvfailedState = False
..IsClusterVolume = True
..IsConstituent = False
..IsInconsistent = False
..IsInvalid = False
..IsJunctionActive =
..IsMoving = False
..IsNodeRoot = False
..IsNvfailEnabled = False
..IsQuiescedInMemory = False
..IsQuiescedOnDisk = False
..IsUnrecoverable = False
..IsVolumeInCutover = False
..State = online
.VolumeStripingAttributes =
.VolumeTransitionAttributes
..IsCopiedForTransition = False
..IsTransitioned = False
..TransitionBehavior = none
.VolumeVmAlignAttributes =
.Aggregate = aggr1
.Available = 2039791616
.Dedupe = False
.FilesTotal = 62244
.FilesUsed = 116
.IsInfiniteVolume = False
.JunctionPath =
.State = online
.TotalSize = 2147483648
.Used = 5
This comment has been removed by the author.
ReplyDelete