I noticed in your previous code, you had specified "ascending" in the "Sort-Object" flags. An ascending sort is the default, and cannot be specified by flag. To sort in descending order, please make sure that "-descending" flag includes the "-" at the beginning of the word.
Below are 3 PS snippets that offer different sorted output.
#Provides a list of LUNs sorted by LunID in ascending order without respect to the igroup name
Get-NaIgroup | ForEach-Object {$_.Initiators} | Get-NaLunMapByInitiator | Sort-Object -Property LunId | Format-Table LunID,InitiatorGroup,Path -autosize
#Provides a list of LUNs sorted by LunID in descending order without respect to the igroup name
Get-NaIgroup | ForEach-Object {$_.Initiators} | Get-NaLunMapByInitiator | Sort-Object -Property LunId -descending | Format-Table LunID,InitiatorGroup,Path -autosize
#Provides a list of LUNs sorted by LunID in descending order and by igroup name in ascending order
$igroups = Get-NaIgroup | Sort-Object -Property InitiatorGroupName
$table = foreach ($igroup in $igroups) {
$igroup.Initiators | Get-NaLunMapByInitiator | Sort-Object -Property LunId -Descending
}
$table | Format-Table LunID,InitiatorGroup,Path -autosize
Please let me know which of these (if any) resolves the problem.
Bill