Cisco UCS “get-ucsNetworkelement”

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

Below is the script I use to collect information from the Cisco UCS Fabric interconnects.

$getucsNetworkelement = “get-ucsNetworkelement | select AdminInBandIfState,ID,InBandIfGW,InBandMask,InBandIfVnet,InventoryStatus,OobIfIP,Model,OobIfGW,OobIfMask,Operability,Revision,Serial,Thermal,TotalMemory,Dn,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-ucsNetworkelementget-ucsNetworkelement

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

 

Script is below

get-ucsNetworkelementget-ucsNetworkelement

#Powershell Invoke Command
$getucsNetworkelement = “get-ucsNetworkelement | select AdminInBandIfState,ID,InBandIfGW,InBandMask,InBandIfVnet,InventoryStatus,OobIfIP,Model,OobIfGW,OobIfMask,Operability,Revision,Serial,Thermal,TotalMemory,Dn,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_FABRIC_INTERCONNECT INFORMATION
#create the file path for exporting FI data.
$getUCSFIFilePath = $dirRoot + “get-FI_” + $ucsconnection.ucs + “.csv”
#get UCS fabric Interconnect info.
invoke-expression $getUCSNetworkElement | export-csv $getUCSFIFilePath -delimiter ^ -notype
#Take out the quotation marks in the CSV files.
(get-content $getUCSFIFilePath ) | % {$_ -replace ‘”‘, “”} | out-file $getUCSFIFilePath -Fo -En ascii
#—————————————————————-
#disconnect from the system
disconnect-ucs
}