get-UCSCHASSIS

Cisco UCS “get-UCSCHASSIS”

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

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

$getUCSCHASSIS = “get-UCSCHASSIS | select AckProgressIndicator,AdminState,ConfigState,FabricEpDn,Id,LcTs,LicGP,LicState,ManagingInst,MfgTime,Model,Operability,OperQualifier,OperState,Power,Presence,Revision,SeePromOperState,Serial,Thermal,ThermalState,UsrLbl,Dn,VersionHolder,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.

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

 

Script is below get-UCSChassis.

get-UCSCHASSIS get-UCSCHASSIS 

##Powershell Invoke Command
$getUCSCHASSIS = “get-UCSCHASSIS | select AckProgressIndicator,AdminState,ConfigState,FabricEpDn,Id,LcTs,LicGP,LicState,ManagingInst,MfgTime,Model,Operability,OperQualifier,OperState,Power,Presence,Revision,SeePromOperState,Serial,Thermal,ThermalState,UsrLbl,Dn,VersionHolder,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-CHASSIS
#create the file path for exporting chassis data.
$getUCSChassisFilePath = $dirRoot + “get-chassis_” + $ucsconnection.ucs + “.csv”
#get ucs Chassis info.
invoke-expression $getUCSChassis | export-csv $getUCSChassisFilePath -delimiter ^ -notype
#Take out the quotation marks in the CSV files.
(get-content $getUCSChassisFilePath ) | % {$_ -replace ‘”‘, “”} | out-file $getUCSChassisFilePath -Fo -En ascii
#—————————————————————-
#disconnect from the system
disconnect-ucs
}