get-UCSserviceprofiles


Cisco UCS “get-UCSserviceprofiles”

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

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

$getUCSserviceprofiles = “get-UCSserviceprofile |select AgentPolicy,AssignState,AssocState,BiosProfileName,BootPolicyName,ConfigState,Descr,DynamicConPolicyName,ExtIPPoolName,ExtIPState,HostFwPolicyName,IdentPoolName,LocalDiskPolicyName,MaintPolicyName,MgmtAccessPolicyName,MgmtFwPolicyName,Name,OperBiosProfileName,OperBootPolicyName,OperDynamicConPolicyName,OperExtIPPoolName,OperHostFwPolicyName,OperIdentPoolName,OperLocalDiskPolicyName,OperMaintPolicyName,OperMgmtAccessPolicyName,OperMgmtFwPolicyName,OperPowerPolicyName,OperScrubPolicyName,OperSolPolicyName,OperSrcTemplName,OperState,OperStatsPolicyName,OperVConProfileName,Owner,PnDn,PolicyLevel,PolicyOwner,PowerPolicyName,ScrubPolicyName,SolPolicyName,SrcTemplName,StatsPolicyName,Type,UsrLbl,UUID,DN,UUIDSuffix,vConProfileName,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-UCSserviceprofile

get-UCSserviceprofile, get-UCSserviceprofile

##Powershell Invoke Command
$getUCSserviceprofiles = “get-UCSserviceprofile |select AgentPolicy,AssignState,AssocState,BiosProfileName,BootPolicyName,ConfigState,Descr,DynamicConPolicyName,ExtIPPoolName,ExtIPState,HostFwPolicyName,IdentPoolName,LocalDiskPolicyName,MaintPolicyName,MgmtAccessPolicyName,MgmtFwPolicyName,Name,OperBiosProfileName,OperBootPolicyName,OperDynamicConPolicyName,OperExtIPPoolName,OperHostFwPolicyName,OperIdentPoolName,OperLocalDiskPolicyName,OperMaintPolicyName,OperMgmtAccessPolicyName,OperMgmtFwPolicyName,OperPowerPolicyName,OperScrubPolicyName,OperSolPolicyName,OperSrcTemplName,OperState,OperStatsPolicyName,OperVConProfileName,Owner,PnDn,PolicyLevel,PolicyOwner,PowerPolicyName,ScrubPolicyName,SolPolicyName,SrcTemplName,StatsPolicyName,Type,UsrLbl,UUID,DN,UUIDSuffix,vConProfileName,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_Service_PROFILES
#create the file path for exporting Service Profile data.
$getUCSServiceProfileFilePath = $dirRoot + “get-ServiceProfile_” + $ucsconnection.ucs + “.csv”
#get ucs Service Profile info.
invoke-expression $getUCSServiceProfiles | export-csv $getUCSServiceProfileFilePath -delimiter ^ -notype
#Take out the quotation marks in the CSV files.
(get-content $getUCSServiceProfileFilePath ) | % {$_ -replace ‘”‘, “”} | out-file $getUCSServiceProfileFilePath -Fo -En ascii
#—————————————————————-
#disconnect from the system
disconnect-ucs
}