Cisco UCS “get-UCSblade”

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

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

$getUCSblade = “get-UCSblade | select AdminPower,AdminState,AssignedtoDN,Association,Availability,AvailableMemory,ChassisId,CheckPoint,Descr,Discovery,Lc,LCTs,LowVoltageMemory,ManagingInst,MemorySpeed,MfgTime,Model,Name,NumofAdapters,NumofCores,NumofCoresEnabled,NumofCPUs,NumofethHostIfs,NumofFcHostIfs,NumOfThreads,OperPower,OperState,Operability,OriginalUUID,PartNumber,PolicyLevel,PolicyOwner,Presence,Revision,Serial,ServerId,SlotId,TotalMemory,UsrLbl,UUID,Vid,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-UCSbladeget-UCSbladeget-UCSbladeget-UCSblade

get-ucsNetworkelementget-ucsNetworkelement

##Powershell Invoke Command
$getUCSblade = “get-UCSblade | select AdminPower,AdminState,AssignedtoDN,Association,Availability,AvailableMemory,ChassisId,CheckPoint,Descr,Discovery,Lc,LCTs,LowVoltageMemory,ManagingInst,MemorySpeed,MfgTime,Model,Name,NumofAdapters,NumofCores,NumofCoresEnabled,NumofCPUs,NumofethHostIfs,NumofFcHostIfs,NumOfThreads,OperPower,OperState,Operability,OriginalUUID,PartNumber,PolicyLevel,PolicyOwner,Presence,Revision,Serial,ServerId,SlotId,TotalMemory,UsrLbl,UUID,Vid,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-BLADES

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