get-UCSVLAN

Cisco UCS “get-UCSVLAN”

In the previous post i explained how I collect information from Cisco UCS hardware using powershell, variables and loops. get-UCSVLAN, get-UCSVLAN

Below is the script I use to collect the Cisco UCS VLAN information.

$getUCSVLAN = “get-UCSVLAN | select Cloud,CompressionType,ConfigIssues,DefaultNet,epDn,ID,IfRole,IfType,Locale,McastPolicyName,Name,OperMCastPolicyName,OperState,PeerDn,PubNwDn,PubNwName,Sharing,SwitchId,Dn,Transport,Type,Rn,Status,UCS”

This script is the used when connecting to the environment within a loop in powershell.

The script will connect to the UCS POD, create the output files, invoke the expression above executing the script, this information is collected in a .csv file with the delimiter set to a “^” symbol rather than a comma. get-UCSserviceprofile, get-UCSserviceprofile

The .csv file is then opened and the “Quotes” are removed ready to be pushed into a Microsoft SQL Database.

 

Script is below get-UCSVLAN.

get-UCSVLAN, get-UCSVLAN

##Powershell Invoke Command
$getUCSVLAN = “get-UCSVLAN | select Cloud,CompressionType,ConfigIssues,DefaultNet,epDn,ID,IfRole,IfType,Locale,McastPolicyName,Name,OperMCastPolicyName,OperState,PeerDn,PubNwDn,PubNwName,Sharing,SwitchId,Dn,Transport,Type,Rn,Status,UCS”
# Create the Foreach Loop for the commands to run
foreach ($UCSPOD in $UCSPODS) {
#connect to the UCS system
$ucsConnection = Connect-Ucs $UCSPOD -Credential $cred

#GET_VLANs
#create the file path for exporting VLAN data.
$getUCSVLANFilePath = $dirRoot + “get-VLAN_” + $ucsconnection.ucs + “.csv”
#get ucs VLAN info.
invoke-expression $getUCSVLAN | export-csv $getUCSVLANFilePath -delimiter ^ -notype
#Take out the quotation marks in the CSV files.
(get-content $getUCSVLANFilePath ) | % {$_ -replace ‘”‘, “”} | out-file $getUCSVLANFilePath -Fo -En ascii
#—————————————————————-
#disconnect from the system
disconnect-ucs
}