Pages

12/18/2014

Powershell Report HP Virtual Connect VLANs

Create a report from HP virtual connect for all VLAN's defined in each server profile.

$cmd = 'C:\Program Files\HP\Virtual Connect Enterprise Manager\Virtual Connect Enterprise Manager CLI\vcemcli.exe'
 $arg1 = '-export'
 $arg2= 'profiles'
 $arg3 = '-exportfile'
 $arg4 = 'profiles.csv'
 &$CMD $arg1 $arg2 $arg3 $arg4
 $raw = ".\profiles.csv" | import-csv -header ''
 $list = $raw | format-list -property "Profile Name", "*Network Name" | out-string 
 $list = $list.split("`n")
 foreach ($item in $list) { 
  $item = $item.replace("`n","")
  $descr = $item.split(":")[0]
  $value = $item.split(":")[1]
  if ( $descr -like "Profile Name*") { 
   write-output "-----------------------------"
   write-output $value
   }
  else { 
   if ( $value -notlike "*N/A*") {
    write-output "    $value"
    }
   }
  }

No comments: