Very good stuff! I wrote a script some time ago that does the same thing. THis can be exported to Excel:
function GetIgroupHost()
{
<#
.SYNOPSIS
Returns the name of the Host Server mapped to the given igroup. It parses the iGroup name to get this information, and assumes the iGroup was automatically created by SnapDrive.
.PARAMETER iGroup
The iGroup object to get the host from.
.EXAMPLE
$hosts = Get-NaIgroup | GetIgroupHost
#>
param
(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)] $iGroup
)
process
{
$hostName = ""
if ( $iGroup )
{
if ( ($iGroup.Name -split "\.").Count -gt 1 )
{
$hostName = ($iGroup.Name -split "\.")[2]
}
else
{
$hostName = $iGroup.Name
}
}
return $hostName
}
}
function GetConnectedController()
{
<#
.SYNOPSIS
Returns the currently-connected controller if one exists.
#>
if ( (Get-Variable | ? { $_.Name -ieq "global:CurrentNaController" }) -and $global:CurrentNaController )
{
return $global:CurrentNaController
}
}
function GetVolumes()
{
param
(
[Parameter(Position=0)][string] $NameFilter,
$Controller
)
<#
.SYNOPSIS
Helper function that retrieves the volumes from a NetApp controller, including any luns and mappings. Adds the following properties:
[Volume].Luns[]
.[Lun].Maps[]
.[Lun].Mappedto(string)
.PARAMETER Controller
If specified, then queries the given controller. Can specify either a controller name or Controller Connection (from Connect-NaController). If unspecified, then uses the currently-connected controller. If no
controller is connected, it will prompt you.
.PARAMETER NameFilter
If specified, uses the given value as a regex and only returns volumes whose names match the filter.
.EXAMPLE
Connect-NaController ctrl1 -RPC
GetVolumes
.EXAMPLE
GetVolumes -Controller ah-3240-1 -NameFilter monitor
#>
$ctrlConnection = $null
if ( !$Controller )
{
# Controller not specified:
if ( GetConnectedController )
{
# Use already-connected controller:
$ctrlConnection = GetConnectedController
}
else
{
# Controller not specified:
$Controller = Read-Host "Specify a controller to query"
$ctrlConnection = Connect-PlexController -Controller $Controller -Passthru
}
}
else
{
# Controller specified:
if ( $Controller -is [string] )
{
$ctrlConnection = Connect-PlexController -Controller $Controller -Passthru -Transient
}
else
{
$ctrlConnection = $Controller
}
}
if ( !$ctrlConnection -or $ctrlConnection -isnot [NetApp.Ontapi.Filer.NaController] )
{
# No controller specified, or invalid:
throw ("You must either specify -Controller or be already connected to one before calling this function!")
}
$vols = Get-NaVol -Controller $ctrlConnection | ? { !$NameFilter -or $_.Name -imatch $NameFilter }
foreach ( $vol in $vols )
{
$luns = @(Get-NaLun -Controller $ctrlConnection -Terse -Path ("/vol/{0}/*" -f $vol.Name))
$vol | Add-Member -MemberType NoteProperty -Name "luns" -Value $luns
if ( $luns )
{
foreach ( $lun in $luns )
{
$maps = @($lun | Get-NaLunMap -Controller $ctrlConnection)
$lun | Add-Member -MemberType NoteProperty -Name "maps" -Value $maps
$lun | Add-Member -MemberType ScriptProperty -Name "MappedTo" -Value `
{
if ( $this.maps )
{
$this.maps | getigrouphost
}
}
}
}
}
$vols
}
$controllers = "filer1","filer2"
$vols = @()
foreach ( $ctrl in $controllers )
{
Connect-NaController $ctrl -RPC
$vols += GetVolumes
}
# Export to Excel
$vols | % { $_.Luns } | Select-Object @{"Label"="volume";"expression"={($_.path -split "/")[2]}},Path,MappedTo | Export-Csv -NoTypeInformation -Path C:\Temp\excel.csv