12-20-2022 01:27 AM
Hi,
I am looking for a script to get the wwpn, overall state, assigned, associated state of all the servers in UCSM.
I can run one script for wwpn and another script for overall state, assigned, associated state. But when I try to combine both, it doesn't work. Any suggestions or any other script that can be checked?
Get-UcsServiceProfile -type instance | Get-UcsVhba | Select Dn,Addr |Export-Csv C:\test.CSV
Get-UcsServiceProfile -type instance|Select AssignState,AssocState,OperState |Export-Csv C:\test.CSV
12-20-2022 07:13 AM
Since its two distinct cmdlets and there can be multiples vhbas you'd need to loop & parse the data in the output format you are looking for.
$Results = @()
$profiles = Get-UcsServiceProfile -type instance
foreach ($profile in $profiles)
{
$vhba = $profile | Get-UcsVhba
$Properties = @{
Name = $profile.Name
AssignState = $profile.AssignState
AssocState = $profile.AssocState
OperState = $profile.OperState
Dn = $vhba.Dn
Wwpn = $vhba.Addr
}
$Results += New-Object psobject -Property $properties
}
$Results | Select Name,AssignState,AssocState,OperState,{$_.Dn -join ','},{$_.Wwpn -join ','} | ConvertTo-Csv
This would put a single profile on a line with the WWPNs and vHBA DNs concatenated together in a single column (additional work would be needed to separate each individual WWPN/DN into its own column on the same line).
"Profile1","failed","unassociated","config-failure","",""
"Profile2","assigned","associated","degraded","",""
"Profile3","unassigned","unassociated","unassociated","org-root/ls-Profile3/fc-a,org-root/ls-Profile3/fc-b","20:00:00:25:AA:00:00:00,20:00:00:25:BB:00:00:00"
"Profile4","unassigned","unassociated","unassociated","org-root/ls-Profile4/fc-a,org-root/ls-Profile4/fc-b","20:00:00:25:B5:00:00:00,20:00:00:25:B5:00:00:01"
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide