ONTAP Discussions

How to get Volume Type using Powershell Toolkit

JimRobertson
15,104 Views

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.

1 ACCEPTED SOLUTION

asulliva
15,053 Views

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.

 

Andrew

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

View solution in original post

10 REPLIES 10

mbeattie
15,065 Views

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
rw

/Matt

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

JimRobertson
14,988 Views

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!

asulliva
15,054 Views

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.

 

Andrew

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

JGPSHNTAP
15,019 Views

^^

 

My response as well.

 

 

esxi
13,550 Views

Thanks

 

How can i set security style ?

esxi
13,542 Views

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

JimRobertson
13,178 Views

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 } }

 

Dinesh_83
9,657 Views

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 } }

 

JimRobertson
9,626 Views

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 *

Dinesh_83
9,579 Views

Thanks this works 🙂

Public