Microsoft Virtualization Discussions

Get-NcLun - Find/List lun by specifying serialnumber

donn
4,669 Views

Trying to figure out the capabilities (How do I use it) of the Get-NcLun -Query command.  My goal is to match/find a lun by specifying the serial number.  I can't figure the command line syntax for this -Query option.  Is anyone familiar with the correct syntax?  Thanks

-Query <LunInfo>

     For advanced queries, provide a LunInfo object with various fields set to indicate which records to retrieve.

     Other fields should remain set to null.  Use "Get-NcLun -Template" to get the initially empty LunInfo object.

More Info:

PS C:\Users\administrator> Get-NcLun | get-member


   TypeName: DataONTAP.C.Types.Lun.LunInfo

Name                               MemberType     Definition
----                               ----------     ----------
Protocol                           AliasProperty  Protocol = MultiProtocolType
Equals                             Method         bool Equals(System.Object obj)
GetHashCode                        Method         int GetHashCode()
GetType                            Method         type GetType()
ToString                           Method         string ToString()
Validate                           Method         System.Void Validate()
Alignment                          Property       System.Object Alignment {get;set;}
BackingSnapshot                    Property       System.Object BackingSnapshot {get;set;}
BlockSize                          Property       System.Object BlockSize {get;set;}
CloneBackingSnapshot               Property       System.Object CloneBackingSnapshot {get;set;}
Comment                            Property       System.Object Comment {get;set;}
CreationTimestamp                  Property       System.Object CreationTimestamp {get;set;}
CreationTimestampDT                Property       System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Cul...
DeviceBinaryId                     Property       System.Object DeviceBinaryId {get;set;}
DeviceId                           Property       System.Object DeviceId {get;set;}
DeviceIdSpecified                  Property       System.Boolean DeviceIdSpecified {get;set;}
DeviceTextId                       Property       System.Object DeviceTextId {get;set;}
IsSpaceAllocEnabled                Property       System.Nullable`1[[System.Boolean, mscorlib, Version=2.0.0.0, Cult...
IsSpaceAllocEnabledSpecified       Property       System.Boolean IsSpaceAllocEnabledSpecified {get;set;}
IsSpaceReservationEnabled          Property       System.Nullable`1[[System.Boolean, mscorlib, Version=2.0.0.0, Cult...
IsSpaceReservationEnabledSpecified Property       System.Boolean IsSpaceReservationEnabledSpecified {get;set;}
Mapped                             Property       System.Nullable`1[[System.Boolean, mscorlib, Version=2.0.0.0, Cult...
MappedSpecified                    Property       System.Boolean MappedSpecified {get;set;}
MultiprotocolType                  Property       System.Object MultiprotocolType {get;set;}
NcController                       Property       NetApp.Ontapi.Filer.C.NcController NcController {get;set;}
Online                             Property       System.Nullable`1[[System.Boolean, mscorlib, Version=2.0.0.0, Cult...
OnlineSpecified                    Property       System.Boolean OnlineSpecified {get;set;}
Path                               Property       System.Object Path {get;set;}
PrefixSize                         Property       System.Object PrefixSize {get;set;}
Qtree                              Property       System.Object Qtree {get;set;}
ReadOnly                           Property       System.Nullable`1[[System.Boolean, mscorlib, Version=2.0.0.0, Cult...
ReadOnlySpecified                  Property       System.Boolean ReadOnlySpecified {get;set;}
SerialNumber                       Property       System.Object SerialNumber {get;set;}
ShareState                         Property       System.Object ShareState {get;set;}
Size                               Property       System.Object Size {get;set;}
SizeUsed                           Property       System.Object SizeUsed {get;set;}
Staging                            Property       System.Nullable`1[[System.Boolean, mscorlib, Version=2.0.0.0, Cult...
StagingSpecified                   Property       System.Boolean StagingSpecified {get;set;}
SuffixSize                         Property       System.Object SuffixSize {get;set;}
Uuid                               Property       System.Object Uuid {get;set;}
Volume                             Property       System.Object Volume {get;set;}
Vserver                            Property       System.Object Vserver {get;set;}
Thin                               ScriptProperty System.Object Thin {get=if (!($this.IsSpaceReservationEnabledSpeci...

1 ACCEPTED SOLUTION

beam
4,669 Views

You can use the -Template switch on Get-NcLun to get an empty LunInfo object.  Then you set the fields to the values you want to query on the LunInfo object, leaving the other fields null.  For example, to get a specific LUN by its serial number:

PS C:\Users\Administrator> $query = Get-NcLun -Template

PS C:\Users\Administrator> $query.SerialNumber = '7T5G6+3iH8Qa'

PS C:\Users\Administrator> Get-NcLun -Query $query

Path                                           Size Protocol     Online Mapped  Thin  Vserver              Comment

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

/vol/clusterdisks/disk0                    200.0 GB windows_2008  True   True   True  beam01

If you are using PowerShell 3, you can do this in one line:

PS C:\Users\Administrator> Get-NcLun -Query @{SerialNumber='7T5G6+3iH8Qa'}

Path                                           Size Protocol     Online Mapped  Thin  Vserver              Comment

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

/vol/clusterdisks/disk0                    200.0 GB windows_2008  True   True   True  beam01

You can also build more complex queries, such as this one to get all online, mapped, and thin LUNs that are bigger than 200GB:

PS C:\Users\Administrator> Get-NcLun -Query @{Online=$true; Mapped=$true; Thin=$true; Size=">$(200GB)"}

Path                                           Size Protocol     Online Mapped  Thin  Vserver              Comment

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

/vol/clusterdisks/disk0                    200.0 GB windows_2008  True   True   True  beam01

/vol/clusterdisks/disk1                      1.0 TB windows_2008  True   True   True  beam01

/vol/powershell/luns/cluster                 1.0 TB windows_2008  True   True   True  beam01

/vol/powershell/luns/disk0                   1.0 TB windows_2008  True   True   True  beam01

-Steven

View solution in original post

2 REPLIES 2

vinith
4,669 Views

I guess you can just do simple powershell pipe lining to get the output

An example below.

Get-NcLun | ?{$_.serialnumber -eq "-dPw6$8rC3rz"}

beam
4,670 Views

You can use the -Template switch on Get-NcLun to get an empty LunInfo object.  Then you set the fields to the values you want to query on the LunInfo object, leaving the other fields null.  For example, to get a specific LUN by its serial number:

PS C:\Users\Administrator> $query = Get-NcLun -Template

PS C:\Users\Administrator> $query.SerialNumber = '7T5G6+3iH8Qa'

PS C:\Users\Administrator> Get-NcLun -Query $query

Path                                           Size Protocol     Online Mapped  Thin  Vserver              Comment

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

/vol/clusterdisks/disk0                    200.0 GB windows_2008  True   True   True  beam01

If you are using PowerShell 3, you can do this in one line:

PS C:\Users\Administrator> Get-NcLun -Query @{SerialNumber='7T5G6+3iH8Qa'}

Path                                           Size Protocol     Online Mapped  Thin  Vserver              Comment

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

/vol/clusterdisks/disk0                    200.0 GB windows_2008  True   True   True  beam01

You can also build more complex queries, such as this one to get all online, mapped, and thin LUNs that are bigger than 200GB:

PS C:\Users\Administrator> Get-NcLun -Query @{Online=$true; Mapped=$true; Thin=$true; Size=">$(200GB)"}

Path                                           Size Protocol     Online Mapped  Thin  Vserver              Comment

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

/vol/clusterdisks/disk0                    200.0 GB windows_2008  True   True   True  beam01

/vol/clusterdisks/disk1                      1.0 TB windows_2008  True   True   True  beam01

/vol/powershell/luns/cluster                 1.0 TB windows_2008  True   True   True  beam01

/vol/powershell/luns/disk0                   1.0 TB windows_2008  True   True   True  beam01

-Steven

Public