Hi,
Please help as I am unable to sort the column output for "LUN ID"
Get-NSVolume | Select @{N="Vol_Name";E={$_.name}},
@{N="Size(GB)";E={[math]::Round($_.size/1024,2)}},
@{N="EUI";E={$_.serial_number}},
@{N="Status";E={$_.vol_state}},
@{N="IG_Name";E={((Get-NSAccessControlRecord -vol_name $_.name).Initiator_group_name) -Join ('|').Replace('|',"`r`n")}},
@{N="LUN_ID";E={((Get-NSAccessControlRecord -vol_name $_.name).lun) -Join ('|').Replace('|',"`r`n")}} | sort "LUN_ID" | ConvertTo-Html -Head $Header -PreContent "<p><h2>Volume - Initiator Groups Info</h2></p>" -PostContent $post | Set-AlternatingRows -CSSEvenClass even -CSSOddClass odd | ForEach-Object -Process { $_ -replace "`n", "<br>" } >> $reportlocation
What exactly is in the calculated property LUN_ID?
The Sort-Object cmdlet will interpret this property as a String, so if you want to sort on numerical values in that string, you will have to convert the parts into Int.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
What exactly is in the calculated property LUN_ID?
The Sort-Object cmdlet will interpret this property as a String, so if you want to sort on numerical values in that string, you will have to convert the parts into Int.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
LUD ID is a numerical number.
you mean like this ?
Sort-Object -Property {[int]$_.''LUN ID"}
Yes, if the property only contains numbers.
But I'm not sure what the Join and Replace are doing.
Can you show sample content of that property?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That worked LucD 🙂 Thank you very much.
I am not sure, why Join and Replace was added, i removed and ran the script that didnt make any difference.
Hence I used {[int]$_."LUN_ID"} that worked.