NetApp sdcli disk list to CSV with Powershell

#NetApp #sdcli #Powershell

So I have been breaking playing around with Jetstress, NetApp filers and Cisco UCS.  Not have much fun or luck, as I just cant get the damn thing to pass even a simple test.  But that is another story!

I have been looking at sdcli and getting some powershell automation going, and I wanted to find out details of all the disks connected to my severs.  Now sdcli is the worst thing in the word for getting anything decent out, so I wrote the following.  Basically run it on a server with NetApp SnapDrive and it will give you a CSV file with the output of sdcli disk list.  Shweet ;-)   It crude but effective!



$diskInfo = Invoke-Expression “sdcli disk list”$tmpsdcliDiskListMatrix = @()
ForEach($Item in $DiskInfo){
$tmpItem = $Item.Trim()
$tmpItemSplit = $tmpItem.Split(“:”)
Switch -Wildcard ($tmpItem){
“UNC Path:*”  {$tmpsdcliDiskListMatrix  += $sdcliDiskList
$sdcliDiskList = “” | Select UNCPath, LUNPath, StorageSystem, StorageSystemPath, Type, Diskserialnumber, BackedbySnapshotCopy, Shared, BootOrSystemDisk, SCSIport, Bus, Target, LUN, Readonly, Size, SnapmirrorSource, SnapvaultPrimary, DiskPartitionStyle, CloneSplitRestorestatus, DiskID, VolumeName, Mountpoints, IPAddresses, FCinitiatorWWPN
$sdcliDiskList.UNCPath = $tmpItemSplit[-1]}
“LUN Path:*”                  {$sdcliDiskList.LUNPath = $tmpItemSplit[-1]}
“Storage System:*”            {$sdcliDiskList.StorageSystem = $tmpItemSplit[-1].trim()}
“Storage System Path:*”       {$sdcliDiskList.StorageSystemPath = $tmpItemSplit[-1].trim()}
“Type:*”                      {$sdcliDiskList.Type = $tmpItemSplit[-1].trim()}
“Disk serial number:*”        {$sdcliDiskList.Diskserialnumber = $tmpItemSplit[-1].trim()}
“Backed by Snapshot Copy:*”   {$sdcliDiskList.BackedbySnapshotCopy = $tmpItemSplit[-1].trim()}
“Shared:*”                    {$sdcliDiskList.Shared = $tmpItemSplit[-1].trim()}
“BootOrSystem Disk:*”          {$sdcliDiskList.BootOrSystemDisk = $tmpItemSplit[-1].trim()}
“SCSI port:*”                  {$sdcliDiskList.SCSIport = $tmpItemSplit[-1].trim()}
“Bus:*”                        {$sdcliDiskList.Bus = $tmpItemSplit[-1].trim()}
“Target:*”                     {$sdcliDiskList.Target = $tmpItemSplit[-1].trim()}
“LUN:*”                        {$sdcliDiskList.Lun = $tmpItemSplit[-1].trim()}
“Readonly:*”                   {$sdcliDiskList.Readonly = $tmpItemSplit[-1].trim()}
“Size:*”                       {$sdcliDiskList.Size = $tmpItemSplit[-1].trim()}
“Snapmirror Source:*”          {$sdcliDiskList.SnapmirrorSource = $tmpItemSplit[-1].trim()}
“Snapvault Primary:*”          {$sdcliDiskList.SnapvaultPrimary = $tmpItemSplit[-1].trim()}
“Disk Partition Style:*”       {$sdcliDiskList.DiskPartitionStyle = $tmpItemSplit[-1].trim()}
“Clone Split Restore status:*” {$sdcliDiskList.CloneSplitRestorestatus = $tmpItemSplit[-1].trim()}
“DiskID:*”                     {$sdcliDiskList.DiskID = $tmpItemSplit[-1].trim()}
“Volume Name:*”                {$sdcliDiskList.VolumeName = $tmpItemSplit[-1].trim()}
“*Mount points:*”              {$sdcliDiskList.Mountpoints = $tmpItem.Split(“`t”)[-1].trim()}
“IP Addresses:*”               {$sdcliDiskList.IPAddresses = $tmpItemSplit[-1].trim()}
“FC initiator WWPN:*”          {$sdcliDiskList.FCinitiatorWWPN = $tmpItem.Split(“`t”)[-1].trim()}

$tmpsdcliDiskListMatrix  | Export-Csv SDCLIDisks.csv -NoTypeInformation -Delimiter “|”