cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
cancel
447
Views
0
Helpful
1
Replies

Script required to get wwpn and OperState,AssocState,AssignState

mkrishaan10
Level 1
Level 1

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

1 Reply 1

Brian Morrissey
Cisco Employee
Cisco Employee

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"

 

Review Cisco Networking products for a $25 gift card