ONTAP Discussions

How to get Volume Type using Powershell Toolkit


From the OnTap CLI, I can run this command to find out my volume type (it will be either RW or DP (for data protection)):

vol show -vserver VserverName -volume VolumeName -fields vserver,volume,state,type


vserver  volume   state  type

-------- -------- ------ ----

VserverName VolumeName online RW



I’d think that the Get-NcVol command should be able to retrieve that data, but that doesn’t seem to be the case:


PS E:\Powershell> Get-NcVol -Name $Mnemonic* -VServer VserverName | Select NcController,Vserver,Name,State,Type



NcController : ControllerName

Vserver      : VserverName

Name         : VolumeName

State        : online

Type         :  



The Type just comes back blank.  I think because it’s not actually an available Property of the volume.


PS E:\Powershell> Get-NcVol | Get-Member -MemberType Properties



   TypeName: DataONTAP.C.Types.Volume.VolumeAttributes


Name                               MemberType     Definition                                                                                                                         

----                               ----------     ----------                                                                                                                          

Name                               Property       string Name {get;set;}                                                                                                             

NcController                       Property       NetApp.Ontapi.Filer.C.NcController NcController {get;set;}                                                                         

Volume64bitUpgradeAttributes       Property       DataONTAP.C.Types.Volume.Volume64bitUpgradeAttributes Volume64bitUpgradeAttributes {get;set;}                                      

VolumeAntivirusAttributes          Property       DataONTAP.C.Types.Volume.VolumeAntivirusAttributes VolumeAntivirusAttributes {get;set;}                                             

VolumeAutobalanceAttributes        Property       DataONTAP.C.Types.Volume.VolumeAutobalanceAttributes VolumeAutobalanceAttributes {get;set;}                                        

VolumeAutosizeAttributes           Property       DataONTAP.C.Types.Volume.VolumeAutosizeAttributes VolumeAutosizeAttributes {get;set;}                                              

VolumeCloneAttributes              Property       DataONTAP.C.Types.Volume.VolumeCloneAttributes VolumeCloneAttributes {get;set;}                                                    

VolumeDirectoryAttributes          Property       DataONTAP.C.Types.Volume.VolumeDirectoryAttributes VolumeDirectoryAttributes {get;set;}                                            

VolumeExportAttributes             Property       DataONTAP.C.Types.Volume.VolumeExportAttributes VolumeExportAttributes {get;set;}                                                  

VolumeFlexcacheAttributes          Property       DataONTAP.C.Types.Volume.VolumeFlexcacheAttributes VolumeFlexcacheAttributes {get;set;}                                            

VolumeHybridCacheAttributes        Property       DataONTAP.C.Types.Volume.VolumeHybridCacheAttributes VolumeHybridCacheAttributes {get;set;}                                         

VolumeIdAttributes                 Property       DataONTAP.C.Types.Volume.VolumeIdAttributes VolumeIdAttributes {get;set;}                                                          

VolumeInfinitevolAttributes        Property       DataONTAP.C.Types.Volume.VolumeInfinitevolAttributes VolumeInfinitevolAttributes {get;set;}                                        

VolumeInodeAttributes              Property       DataONTAP.C.Types.Volume.VolumeInodeAttributes VolumeInodeAttributes {get;set;}                                                    

VolumeLanguageAttributes           Property       DataONTAP.C.Types.Volume.VolumeLanguageAttributes VolumeLanguageAttributes {get;set;}                                               

VolumeMirrorAttributes             Property       DataONTAP.C.Types.Volume.VolumeMirrorAttributes VolumeMirrorAttributes {get;set;}                                                  

VolumePerformanceAttributes        Property       DataONTAP.C.Types.Volume.VolumePerformanceAttributes VolumePerformanceAttributes {get;set;}                                        

VolumeQosAttributes                Property       DataONTAP.C.Types.Volume.VolumeQosAttributes VolumeQosAttributes {get;set;}                                                        

VolumeSecurityAttributes           Property       DataONTAP.C.Types.Volume.VolumeSecurityAttributes VolumeSecurityAttributes {get;set;}                                              

VolumeSisAttributes                Property       DataONTAP.C.Types.Volume.VolumeSisAttributes VolumeSisAttributes {get;set;}                                                        

VolumeSnapshotAttributes           Property       DataONTAP.C.Types.Volume.VolumeSnapshotAttributes VolumeSnapshotAttributes {get;set;}                                              

VolumeSnapshotAutodeleteAttributes Property       DataONTAP.C.Types.Volume.VolumeSnapshotAutodeleteAttributes VolumeSnapshotAutodeleteAttributes {get;set;}                          

VolumeSpaceAttributes              Property       DataONTAP.C.Types.Volume.VolumeSpaceAttributes VolumeSpaceAttributes {get;set;}                                                    

VolumeStateAttributes              Property       DataONTAP.C.Types.Volume.VolumeStateAttributes VolumeStateAttributes {get;set;}                                                    

VolumeStripingAttributes           Property       DataONTAP.C.Types.Volume.VolumeStripingAttributes VolumeStripingAttributes {get;set;}                                              

VolumeTransitionAttributes         Property       DataONTAP.C.Types.Volume.VolumeTransitionAttributes VolumeTransitionAttributes {get;set;}                                           

VolumeVmAlignAttributes            Property       DataONTAP.C.Types.Volume.VolumeVmAlignAttributes VolumeVmAlignAttributes {get;set;}                                                

Vserver                            Property       string Vserver {get;set;}                                                                                                          

Aggregate                          ScriptProperty System.Object Aggregate {get=try { $this.VolumeIdAttributes.ContainingAggregateName } catch [Exception] { $null };set=if($this.Vo...

Available                          ScriptProperty System.Object Available {get=try { $this.VolumeSpaceAttributes.SizeAvailable} catch [Exception] { $null };set=if($this.VolumeSpac...

Dedupe                             ScriptProperty System.Object Dedupe {get=try { $this.VolumeSisAttributes.IsSisVolume } catch [Exception] { $null };set=if($this.VolumeSisAttribu...

FilesTotal                         ScriptProperty System.Object FilesTotal {get=try { $this.VolumeInodeAttributes.FilesTotal } catch [Exception] { $null };set=if($this.VolumeInode...

FilesUsed                          ScriptProperty System.Object FilesUsed {get=try { $this.VolumeInodeAttributes.FilesUsed } catch [Exception] { $null };set=if($this.VolumeInodeAt...

IsInfiniteVolume                   ScriptProperty System.Object IsInfiniteVolume {get=try { if( $this.VolumeIdAttributes.Style -eq 'infinitevol' ) { $true } else { $false } } catc...

JunctionPath                       ScriptProperty System.Object JunctionPath {get=try { $this.VolumeIdAttributes.JunctionPath } catch [Exception] { $null };set=if($this.VolumeIdAt...

State                              ScriptProperty System.Object State {get=try { $this.VolumeStateAttributes.State } catch [Exception] { $null };set=if($this.VolumeStateAttributes...

TotalSize                          ScriptProperty System.Object TotalSize {get=try { $this.VolumeSpaceAttributes.Size } catch [Exception] { $null };set=if($this.VolumeSpaceAttribu...

Used                               ScriptProperty System.Object Used {get=try { $this.VolumeSpaceAttributes.PercentageSizeUsed } catch [Exception] { $null };set=if($this.VolumeSpa...




Does anyone know any other tricks to pull that info back through Powershell?
Other than using the Invoke-NcSsh command that is… the return data from that is such a pain to deal with.


Re: How to get Volume Type using Powershell Toolkit


Hi Jim,


Are these the droids you are looking for?


PS C:\> Import-Module DataONTAP
PS C:\> $credentials = Get-Credential -Credential admin
PS C:\> Connect-NcController -Name cluster1 -HTTPS -Credential $credentials | Out-Null
PS C:\> $volume = Get-NcVol -Vserver vserver1 -Name "volume1"
PS C:\> $volume.VolumeIdAttributes.Type


If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: How to get Volume Type using Powershell Toolkit


Just to expand on what @mbeattie posted a bit, you can get the same info as the CLI using this bit of script:


Get-NcVol | Select Vserver,Name,State,@{ 'Name' = 'Type'; 'Expression' = { $_.VolumeIdAttributes.Type } }

Hope that helps.



If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

View solution in original post

Re: How to get Volume Type using Powershell Toolkit




My response as well.



Re: How to get Volume Type using Powershell Toolkit


Yes, those are indeed the droids I was looking for!  Thank you so much!

I did mark asulliva's follow-up as the accepted solution though, because he answered my follow-up question before I asked it 🙂  I was trying to figure out how to display those attributes along with the others, and that worked quite nicely.

Thanks everyone for your help!

Re: How to get Volume Type using Powershell Toolkit




How can i set security style ?

Re: How to get Volume Type using Powershell Toolkit


i know its VolumeSecurityAttributes but then how to get the dump for all volues is not clear

Re: How to get Volume Type using Powershell Toolkit


For setting the security style, this worked for me:


$volume.VolumeSecurityAttributes.Sytle = "unix"


To get a list of the security type of all volumes:

Get-NcVol | Select Vserver,Name,State,@{ 'Name' = 'Type'; 'Expression' = { $_.VolumeSecurityAttributes.Type } }


Re: How to get Volume Type using Powershell Toolkit


With Powershell command , It does not list Security style I am getting type as blank


Get-NcVol | Select Vserver,Name,State,@{ 'Name' = 'Type'; 'Expression' = { $_.VolumeSecurityAttributes.Type } }


Re: How to get Volume Type using Powershell Toolkit


Not sure if this changed at some point or what, but the property is actually Style, not Type.  So, try this:

Get-NcVol | Select Vserver,Name,State,@{ 'Name' = 'Style'; 'Expression' = { $_.VolumeSecurityAttributes.Style } }

Also, for future troubleshooting, you can list out all the properties of an item and their values  like this:

$Vol = Get-NcVol VolName
$Vol.VolumeSecurityAttributes | Select-Object -Property *

Re: How to get Volume Type using Powershell Toolkit


Thanks this works 🙂

Earn Rewards for Your Review!
GPI Review Banner
All Community Forums