I'm trying to find some orphaned snapmirrors by searching multiple controllers and filtering for snapshots using get-ncsnapshot with "snapmirror" in the name. This is working as expected. In building a query for a report, I want volume attributes on the volume contained in the get-ncvol command, { (Get-NcVol $_.Volume).Aggregate }} for example. This works as expected however; when I try to include an attribute that's nested "@{l = "Voltype"; e = { (Get-NcVol $_.volume).VolumeIdAttributes.Type }}," . The output groups by the volume name.
Note: Any recommandations welcome.
#Connect to Controllers
foreach ($i in @($controllers)) {
Connect-NcController $i
}
foreach ($i in @($controllers)) {
Connect-NcController $i -Credential $credential -Add
}
$date = (Get-Date -Format yy-MM-dd)
$ExcelName = $NcController + '_' + $date + '.xlsx'
$Days = 7
$Daysback = $Days/-1
#
#Snapshot Logic
#
$Snapshots = Get-NcSnapshot |
Where-Object {
$_.Name -match 'snapmirror'
#$_.Created -lt (Get-Date).AddDays($Daysback)
}
$reportData = $Snapshots | Select-Object @{l = "Controller"; e = { (Get-NcVol $_.Volume).NcController }},
@{l = "Vserver"; e = {$_.Vserver}},
@{l = "Aggregate"; e = { (Get-NcVol $_.Volume).Aggregate }},
@{l = "Volume"; e = { (Get-NcVol $_.volume).Name }},
@{l = "SnapName"; e = {$_.Name}},
@{l = "Created"; e = {$_.Created}},
@{l = "Dependency"; e = {$_.Dependency}},
@{l = "State"; e = {$_.State}},
@{l = "Voltype"; e = { (Get-NcVol $_.volume).VolumeIdAttributes.Type }},
@{l = "Cumulative_GB"; e = {$([Math]::Round($_.Cumulative / 1GB, 2)).ToString()}},
@{l = "Total_GB"; e = {$([Math]::Round($_.Total / 1GB, 2)).ToString() }}
$reportData | out-gridview