Skip to content

Instantly share code, notes, and snippets.

@pezhore
Created January 14, 2016 23:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save pezhore/d2816dab34a74c8fa6b6 to your computer and use it in GitHub Desktop.
Save pezhore/d2816dab34a74c8fa6b6 to your computer and use it in GitHub Desktop.
# This will eventually get /seriously/ reworked (into an actual script).
# For now, assume that $ucsVips are configured as an array of strings, and $cred is a PSCredential object
# The resulting $UcsDump object will be used with the PostgreSQL database snippet
# This function is the work horse - connects to UCSM, and proceeds to grab a ton of information.
# It was violently ripped from the Cisco UCS HealthCheck v2.3 script (https://communities.cisco.com/docs/DOC-52398)
function Get-UcsData {
Param ($domain, $creds)
Import-Module CiscoUcsPs
Disconnect-ucs
$handle = Connect-Ucs $domain -Credential $creds
$ProcessHash = @{}
#--- Initialize DomainHash variable for this domain ---#
Start-UcsTransaction -Ucs $handle
$DomainHash = @{}
#$DomainHash.System = @{}
$DomainHash.Inventory = @{}
#$DomainHash.Policies = @{}
#$DomainHash.Profiles = @{}
#$DomainHash.Lan = @{}
#$DomainHash.San = @{}
$DomainHash.Faults = @()
$UcsLocalDiskConfigPolicy = Get-UcsLocalDiskConfigPolicy
$UcsLsBinding = Get-UcsLsBinding
$UcsMaintenancePolicy = get-ucsmaintenancepolicy -ucs $handle
$UcsServerPoolAssignment = Get-UcsServerPoolAssignment
$UcsServerPower = Get-UcsServerPower
$UcsVhba = Get-UcsVhba
$UcsVnic = Get-UcsVnic
$UcsVnicConnDef = Get-UcsVnicConnDef
$UcsVnicFcNode = Get-UcsVnicFcNode
Write-Progress -Activity "Gathering Details on $($handle.ucs)" `
-Status "System Data Collection" `
-PercentComplete 0 `
-Id 0
#===================================#
# Start System Data Collection #
#===================================#
#--- Get UCS Cluster State ---#
$system = Get-UcsStatus -Ucs $handle | Select-Object Name,VirtualIpv4Address,HaReady,FiALeadership,FiAManagementServicesState,FiBLeadership,FiBManagementServicesState
$DomainName = $system.Name
<#
$DomainHash.System.VIP = $system.VirtualIpv4Address
$DomainHash.System.UCSM = (Get-UcsMgmtController -Ucs $handle -Subject system | Get-UcsFirmwareRunning).Version
$DomainHash.System.HA_Ready = $system.HaReady
#--- Get Full State and Logical backup configuration ---#
$DomainHash.System.Backup_Policy = (Get-UcsMgmtBackupPolicy -Ucs $handle | Select AdminState).AdminState
$DomainHash.System.Config_Policy = (Get-UcsMgmtCfgExportPolicy -Ucs $handle | Select AdminState).AdminState
#--- Get Call Home admin state ---#
$DomainHash.System.CallHome = (Get-UcsCallHome -Ucs $handle | Select-Object AdminState).AdminState
#--- Get System and Server power statistics ---#
$DomainHash.System.Chassis_Power = @()
$DomainHash.System.Chassis_Power += Get-UcsChassisStats -Ucs $handle | Select-Object Dn,InputPower,InputPowerAvg,InputPowerMax,OutputPower,OutputPowerAvg,OutputPowerMax,Suspect
$DomainHash.System.Chassis_Power | % {$_.Dn = $_.Dn -replace ('(sys[/])|([/]stats)',"") }
$DomainHash.System.Server_Power = @()
$DomainHash.System.Server_Power += Get-UcsComputeMbPowerStats -Ucs $handle | Sort-Object -Property Dn | Select-Object Dn,ConsumedPower,ConsumedPowerAvg,ConsumedPowerMax,InputCurrent,InputCurrentAvg,InputVoltage,InputVoltageAvg,Suspect
$DomainHash.System.Server_Power | % {$_.Dn = $_.Dn -replace ('([/]board.*)',"") }
#--- Get Server temperatures ---#
$DomainHash.System.Server_Temp = @()
$DomainHash.System.Server_Temp += Get-UcsComputeMbTempStats -Ucs $handle | Sort-Object -Property Ucs,Dn | Select-Object Dn,FmTempSenIo,FmTempSenIoAvg,FmTempSenIoMax,FmTempSenRear,FmTempSenRearAvg,FmTempSenRearMax,FmTempSenRearL,FmTempSenRearLAvg,FmTempSenRearLMax,FmTempSenRearR,FmTempSenRearRAvg,FmTempSenRearRMax,Suspect
$DomainHash.System.Server_Temp | % {$_.Dn = $_.Dn -replace ('([/]board.*)',"") }
#>
#===================================#
# Start Inventory Collection #
#===================================#
#--- Start Fabric Interconnect Inventory Collection ---#
$DomainHash.Inventory.FIs = @()
#--- Iterate through Fabric Interconnects and grab relevant data points ---#
$FIs = Get-UcsNetworkElement -Ucs $handle
Foreach ($fi in $FIs)
{
Write-Progress -Activity "Analyzing FI $($fi.Dn)" `
-Status "FI $($FIs.IndexOf($fi)) of $($FIs.Count)" `
-PercentComplete $(($FIs.IndexOf($fi) / $FIs.Count)*100) `
-Id 1
#--- Store current pipe value to fi variable ---#
#--- Hash variable for storing current FI details ---#
$fiHash = @{}
$fiHash.Dn = $fi.Dn
$fiHash.Fabric_Id = $fi.Id
$fiHash.Operability = $fi.Operability
$fiHash.Thermal = $fi.Thermal
#--- Get leadership role and management service state ---#
if($fi.Id -eq "A")
{
$fiHash.Role = $system.FiALeadership
$fiHash.State = $system.FiAManagementServicesState
}
else
{
$fiHash.Role = $system.FiBLeadership
$fiHash.State = $system.FiAManagementServicesState
}
#--- Get the common name of the fi from the manufacturing definition and format the text ---#
$fiModel = (Get-UcsEquipmentManufacturingDef -Ucs $handle -Filter "Sku -cmatch $($fi.Model)" | Select-Object Name).Name -replace "Cisco UCS ", ""
if($fiModel -is [array]) { $fiHash.Model = $fiModel.Item(0) -replace "Cisco UCS ", "" }
else { $fiHash.Model = $fiModel -replace "Cisco UCS ", "" }
$fiHash.Serial = $fi.Serial
#--- Get FI System and Kernel FW versions ---#
${fiBoot} = Get-UcsMgmtController -Ucs $handle -Dn "$($fi.Dn)/mgmt" | Get-ucsfirmwarebootdefinition | Get-UcsFirmwareBootUnit -Filter 'Type -ieq system -or Type -ieq kernel' | Select-Object Type,Version
$fiHash.System = (${fiBoot} | where {$_.Type -eq "system"}).Version
$fiHash.Kernel = (${fiBoot} | where {$_.Type -eq "kernel"}).Version
#--- Get out of band management IP and Port licensing information ---#
$fiHash.IP = $fi.OobIfIp
$fiHash.Ports_Used = (Get-UcsLicense -Ucs $handle -Scope $fi.Id | Select-Object UsedQuant).UsedQuant
$fiHash.Ports_Licensed = (Get-UcsLicense -Ucs $handle -Scope $fi.Id | Select-Object AbsQuant).AbsQuant
#--- Get Ethernet and FC Switching mode of FI ---#
$fiHash.Ethernet_Mode = (Get-UcsLanCloud -Ucs $handle).Mode
$fiHash.FC_Mode = (Get-UcsSanCloud -Ucs $handle).Mode
#--- Get Local storage, VLAN, and Zone utilization numbers ---#
$fiHash.Storage = $fi | Get-UcsStorageItem | Select Name,Size,Used
$fiHash.VLAN = $fi | Get-UcsSwVlanPortNs | Select Limit,AccessVlanPortCount,BorderVlanPortCount,AllocStatus
$fiHash.Zone = $fi | Get-UcsManagedObject -Classid SwFabricZoneNs | Select-Object Limit,ZoneCount,AllocStatus
#--- Sort Expression to filter port id to be just the numerical port number and sort ascending ---#
$sortExpr = {if ($_.Dn -match "(?=port[-]).*") {($matches[0] -replace ".*(?<=[-])",'') -as [int]}}
#--- Get Fabric Port Configuration and sort by port id using the above sort expression ---#
$fiHash.Ports = Get-UcsFabricPort -Ucs $handle -SwitchId "$($fi.Id)" -AdminState enabled | Sort-Object $sortExpr | Select-Object AdminState,Dn,IfRole,IfType,LicState,LicGP,Mac,Mode,OperState,OperSpeed,XcvrType,PeerDn,PeerPortId,PeerSlotId,PortId,SlotId,SwitchId
$fiHash.FcUplinkPorts = Get-UcsFiFcPort -Ucs $handle -SwitchId "$($fi.Id)" -AdminState 'enabled' -IfRole 'network'
#--- Store fi hash to domain hash variable ---#
$DomainHash.Inventory.FIs += $fiHash
}
Write-Progress -Activity "." -Complete -Id 1
#--- End FI Inventory Collection ---#
#--- Start Chassis Inventory Collection ---#
#--- Initialize array variable for storing Chassis data ---#
$DomainHash.Inventory.Chassis = @()
#--- Iterate through chassis inventory and grab relevant data ---#
$allChassis = Get-UcsChassis -Ucs $handle
foreach ($chassis in $allChassis)
{
Write-Progress -Activity "Analyzing Chassis $($chassis.Dn)" `
-Status "Chassis $($allChassis.IndexOf($chassis)) of $($allChassis.Count)" `
-PercentComplete $(($allChassis.IndexOf($chassis) / $allChassis.Count)*100) `
-Id 1
#--- Hash variable for storing current chassis data ---#
$chassisHash = @{}
$chassisHash.Dn = $chassis.Dn
$chassisHash.Id = $chassis.Id
$chassisHash.Model = $chassis.Model
$chassisHash.Status = $chassis.OperState
$chassisHash.Operability = $chassis.Operability
$chassisHash.Power = $chassis.Power
$chassisHash.Thermal = $chassis.Thermal
$chassisHash.Serial = $chassis.Serial
$chassisHash.Blades = @()
#--- Initialize chassis used slot count to 0 ---#
$slotCount = 0
#--- Iterate through all blades within current chassis ---#
$chassis | Get-UcsBlade | Select Model,SlotId,AssignedToDn | % {
#--- Hash variable for storing current blade data ---#
$bladeHash = @{}
$bladeHash.Model = $_.Model
$bladeHash.SlotId = $_.SlotId
$bladeHash.Service_Profile = $_.AssignedToDn
#--- Get width of blade and convert to slot count ---#
$bladeHash.Width = [math]::floor(((Get-UcsEquipmentPhysicalDef -Filter "Dn -ilike *$($_.Model)*").Width)/8)
#--- Increment used slot count by current blade width ---#
$slotCount += $bladeHash.Width
$chassisHash.Blades += $bladeHash
}
#--- Get Used slots and slots available from iterated slot count ---#
$chassisHash.SlotsUsed = $slotCount
$chassisHash.SlotsAvailable = 8 - $slotCount
#--- Get chassis PSU data and redundancy mode ---#
$chassisHash.Psus = @()
$chassisHash.Psus = $chassis | Get-UcsPsu | Sort Id | Select Type,Id,Model,Serial,Dn
$chassisHash.Power_Redundancy = ($chassis | Get-UcsComputePsuControl | Select Redundancy).Redundancy
#--- Add chassis to domain hash variable ---#
$DomainHash.Inventory.Chassis += $chassisHash
}
#--- End Chassis Inventory Collection ---#
Write-Progress -Activity "." -Complete -Id 1
#--- Start IOM Inventory Collection ---#
#--- Increment job progress ---#
Write-Progress -Activity "Gathering Details on $domain" `
-Status "IOM Details" `
-PercentComplete 24 `
-Id 0
#--- Get all fabric and blackplane ports for future iteration ---#
$FabricPorts = Get-UcsEtherSwitchIntFIo -Ucs $handle
$BackplanePorts = Get-UcsEtherServerIntFIo -Ucs $handle
#--- Initialize array for storing IOM inventory data ---#
$DomainHash.Inventory.IOMs = @()
#--- Iterate through each IOM and grab relevant data ---#
$ioms = Get-UcsIom -Ucs $handle | Select-Object ChassisId,SwitchId,Model,Serial,Dn
foreach ($iom in $ioms)
{
Write-Progress -Activity "Analyzing iom $($iom.Dn)" `
-Status "iom $($ioms.IndexOf($iom)) of $($ioms.Count)" `
-PercentComplete $(($ioms.IndexOf($iom) / $ioms.Count)*100) `
-Id 1
$iomHash = @{}
$iomHash.Dn = $iom.Dn
$iomHash.Chassis = $iom.ChassisId
$iomHash.Fabric_Id = $iom.SwitchId
#--- Get common name of IOM model and format for viewing ---#
$iomHash.Model = (Get-UcsEquipmentManufacturingDef -Ucs $handle -Filter "Sku -cmatch $($iom.Model)").Name -replace "Cisco UCS ", ""
$iomHash.Serial = $iom.Serial
#--- Get the IOM uplink port channel name if configured ---#
$iomHash.Channel = (Get-ucsportgroup -Ucs $handle -Dn "$($iom.Dn)/fabric-pc" | Get-UcsEtherSwitchIntFIoPc).Rn
#--- Get IOM running and backup fw versions ---#
$iomHash.Running_FW = (Get-UcsMgmtController -Ucs $handle -Dn "$($iom.Dn)/mgmt" | Get-UcsFirmwareRunning -Deployment system | Select-Object Version).Version
$iomHash.Backup_FW = (Get-UcsMgmtController -Ucs $handle -Dn "$($iom.Dn)/mgmt" | Get-UcsFirmwareUpdatable | Select-Object Version).Version
#--- Initialize FabricPorts array for storing IOM port data ---#
$iomHash.FabricPorts = @()
#--- Iterate through all fabric ports tied to the current IOM ---#
$FabricPorts | ? {$_.ChassisId -eq "$($iomHash.Chassis)" -and $_.SwitchId -eq "$($iomHash.Fabric_Id)"} | Select-Object SlotId,PortId,OperState,EpDn,PeerSlotId,PeerPortId,SwitchId,Ack,PeerDn | % {
#--- Hash variable for storing current fabric port data ---#
$portHash = @{}
$portHash.Name = 'Fabric Port ' + $_.SlotId + '/' + $_.PortId
$portHash.OperState = $_.OperState
$portHash.PortChannel = $_.EpDn
$portHash.PeerSlotId = $_.PeerSlotId
$portHash.PeerPortId = $_.PeerPortId
$portHash.FabricId = $_.SwitchId
$portHash.Ack = $_.Ack
$portHash.Peer = $_.PeerDn
#--- Add current fabric port hash variable to FabricPorts array ---#
$iomHash.FabricPorts += $portHash
}
#--- Initialize BackplanePorts array for storing IOM port data ---#
$iomHash.BackplanePorts = @()
#--- Iterate through all backplane ports tied to the current IOM ---#
$BackplanePorts | ? {$_.ChassisId -eq "$($iomHash.Chassis)" -and $_.SwitchId -eq "$($iomHash.Fabric_Id)"} | Sort-Object {($_.SlotId) -as [int]},{($_.PortId) -as [int]} | Select-Object SlotId,PortId,OperState,EpDn,SwitchId,PeerDn | % {
#--- Hash variable for storing current backplane port data ---#
$portHash = @{}
$portHash.Name = 'Backplane Port ' + $_.SlotId + '/' + $_.PortId
$portHash.OperState = $_.OperState
$portHash.PortChannel = $_.EpDn
$portHash.FabricId = $_.SwitchId
$portHash.Peer = $_.PeerDn
#--- Add current backplane port hash variable to FabricPorts array ---#
$iomHash.BackplanePorts += $portHash
}
#--- Add IOM to domain hash variable ---#
$DomainHash.Inventory.IOMs += $iomHash
}
Write-Progress -Activity "." -Complete -Id 1
#--- End IOM Inventory Collection ---#
#--- Start Blade Inventory Collection ---#
#--- Get all memory and vif data for future iteration ---#
$memoryArray = Get-UcsMemoryUnit -Ucs $handle
$paths = Get-UcsFabricPathEp -Ucs $handle
#--- Set progress of current job ---#
Write-Progress -Activity "Gathering Details on $domain" `
-Status "Blade Data" `
-PercentComplete 36 `
-Id 0
#--- Initialize array for storing blade data ---#
$DomainHash.Inventory.Blades = @()
#--- Iterate through each blade and grab relevant data ---#
Get-UcsBlade -Ucs $handle | % {
#--- Store current pipe variable to local variable ---#
$blade = $_
#--- Hash variable for storing current blade data ---#
$bladeHash = @{}
$bladeHash.Dn = $blade.Dn
$bladeHash.Status = $blade.OperState
$bladeHash.Chassis = $blade.ChassisId
$bladeHash.Slot = $blade.SlotId
($bladeHash.Model,$bladeHash.Model_Description) = Get-UcsEquipmentManufacturingDef -Ucs $handle -Filter "Sku -ieq $($blade.Model)" | Select Name,Description | % {($_.Name -replace "Cisco UCS ", ""),$_.Description}
$bladeHash.Serial = $blade.Serial
$bladeHash.Uuid = $blade.Uuid
$bladeHash.UsrLbl = $blade.UsrLbl
$bladeHash.Name = $blade.Name
$bladeHash.Service_Profile = $blade.AssignedToDn
#--- If blade doesn't have a service profile set profile name to Unassociated ---#
if(!($bladeHash.Service_Profile))
{
$bladeHash.Service_Profile = "Unassociated"
}
#--- Get blade child object for future iteration ---#
$childTargets = $blade | Get-UcsChild | where {$_.Rn -ieq "bios" -or $_.Rn -ieq "mgmt" -or $_.Rn -ieq "board"} | get-ucschild
#--- Get blade CPU data ---#
$cpu = ($childTargets | where {$_.Rn -match "cpu" -and $_.Model -ne ""} | Select-Object -first 1).Model
#--- Get CPU common name and format text ---#
$bladeHash.CPU_Model = '(' + $blade.NumOfCpus + ') ' + ($cpu.Substring(([regex]::match($cpu,'CPU ').Index) + ([regex]::match($cpu,'CPU ').Length))).Replace(" ","")
$bladeHash.CPU_Cores = $blade.NumOfCores
$bladeHash.CPU_Threads = $blade.NumOfThreads
#--- Format available memory in GB ---#
$bladeHash.Memory = $blade.AvailableMemory/1024
$bladeHash.Memory_Speed = $blade.MemorySpeed
$bladeHash.BIOS = (($childTargets | where {$_.Type -eq "blade-bios"}).Version -replace ('(?!(.*[.]){2}).*',"")).TrimEnd('.')
$bladeHash.CIMC = ($childTargets | where {$_.Type -eq "blade-controller" -and $_.Deployment -ieq "system"}).Version
$bladeHash.Board_Controller = ($childTargets | where {$_.Type -eq "board-controller"}).Version
#--- Set Board Controller model to N/A if not present ---#
if(!($bladeHash.Board_Controller))
{
$bladeHash.Board_Controller = 'N/A'
}
#--- Array variable for storing blade adapter data ---#
$bladeHash.Adapters = @()
#--- Iterate through each blade adapter and grab relevant data ---#
$blade | Get-UcsAdaptorUnit | % {
#--- Hash variable for storing current adapter data ---#
$adapterHash = @{}
#--- Get common name of adapter and format string ---#
$adapterHash.Model = (Get-UcsEquipmentManufacturingDef -Ucs $handle -Filter "Sku -ieq $($_.Model)").Name -replace "Cisco UCS ", ""
$adapterHash.Name = 'Adaptor-' + $_.Id
$adapterHash.Slot = $_.Id
$adapterHash.Fw = ($_ | Get-UcsMgmtController | Get-UcsFirmwareRunning -Deployment system).Version
$adapterHash.Serial = $_.Serial
#--- Add current adapter hash to blade adapter array ---#
$bladeHash.Adapters += $adapterHash
}
#--- Array variable for storing blade memory data ---#
$bladeHash.Memory_Array = @()
#--- Iterage through all memory tied to current server and grab relevant data ---#
$memoryArray | ? {$_.Dn -match $blade.Dn} | Select Id,Location,Capacity,Clock | Sort-Object {($_.Id) -as [int]} | % {
#--- Hash variable for storing current memory data ---#
$memHash = @{}
$memHash.Name = "Memory " + $_.Id
$memHash.Location = $_.Location
#--- Format DIMM capacity in GB ---#
Try
{
$memHash.Capacity = ($_.Capacity)/1024
}
Catch
{
Write-Debug "Error converting Capacity `"$($_.Capacity)` on Blade Dn: $($blade.Dn) to GB"
Write-Verbose "Error converting Capacity `"$($_.Capacity)`" to GB"
}
$memHash.Clock = $_.Clock
$bladeHash.Memory_Array += $memHash
}
#--- Array variable for storing local storage configuration data ---#
$bladeHash.Storage = @()
#--- Iterate through each blade storage controller and grab relevant data ---#
$blade | Get-UcsComputeBoard | Get-UcsStorageController | % {
#--- Store current pipe variable to local variable ---#
$controller = $_
#--- Hash variable for storing current storage controller data ---#
$controllerHash = @{}
#--- Grab relevant controller data and store to respective controllerHash variable ---#
$controllerHash.Id,$controllerHash.Vendor,$controllerHash.Revision,$controllerHash.RaidSupport,$controllerHash.PciAddr,$controllerHash.RebuildRate,$controllerHash.Model,$controllerHash.Serial,$controllerHash.ControllerStatus = $controller.Id,$controller.Vendor,$controller.HwRevision,$controller.RaidSupport,$controller.PciAddr,$controller.XtraProperty.RebuildRate,$controller.Model,$controller.Serial,$controller.XtraProperty.ControllerStatus
$controllerHash.Disk_Count = 0
#--- Array variable for storing controller disks ---#
$controllerHash.Disks = @()
#--- Iterate through each local disk and grab relevant data ---#
$controller | Get-UcsStorageLocalDisk -Presence "equipped" | % {
#--- Store current pipe variable to local variable ---#
$disk = $_
#--- Hash variable for storing current disk data ---#
$diskHash = @{}
#--- Get common name of disk model and format text ---#
$equipmentDef = Get-UcsEquipmentManufacturingDef -Ucs $handle |?{$_.OemPartNumber -match $disk.Model}
#--- Get detailed disk capability data ---#
$capabilities = Get-UcsEquipmentLocalDiskDef -Ucs $handle |?{$_.Dn -match $disk.Model}
$diskHash.Id = $disk.Id
$diskHash.Pid = $equipmentDef.Pid
$diskHash.Vendor = $disk.Vendor
$diskHash.Vid = $equipmentDef.Vid
$diskHash.Serial = $disk.Serial
$diskHash.Product_Name = $equipmentDef.Name
$diskHash.Drive_State = $disk.XtraProperty.DiskState
$diskHash.Power_State = $disk.XtraProperty.PowerState
#--- Format disk size to whole GB value ---#
$diskHash.Size = "{0:N2}" -f ($disk.Size/1024)
$diskHash.Link_Speed = $disk.XtraProperty.LinkSpeed
$diskHash.Blocks = $disk.NumberOfBlocks
$diskHash.Block_Size = $disk.BlockSize
$diskHash.Technology = $capabilities.Technology
$diskHash.Avg_Seek_Time = $capabilities.SeekAverageReadWrite
$diskHash.Track_To_Seek = $capabilities.SeekTrackToTrackReadWrite
$diskHash.Operability = $disk.Operability
$diskHash.Presence = $disk.Presence
$diskHash.Running_Version = ($disk | Get-UcsFirmwareRunning).Version
$controllerHash.Disk_Count += 1
#--- Add current disk hash to controller hash disk array ---#
$controllerHash.Disks += $diskHash
}
#--- Add controller hash variable to current blade hash storage array ---#
$bladeHash.Storage += $controllerHash
}
#--- Array variable for storing VIF information for current blade ---#
$bladeHash.VIFs = @()
#--- Grab all circuits that match the current blade DN and are active or link-down ---#
$circuits = Get-UcsDcxVc -Ucs $handle -Filter "Dn -cmatch $($blade.Dn) -and (OperState -cmatch active -or OperState -cmatch link-down)" | Select Dn,Id,OperBorderPortId,OperBorderSlotId,SwitchId,Vnic,LinkState
#--- Iterate through all paths of type "mux-fabric" for the current blade ---#
$paths | ? {$_.Dn -Match $blade.Dn -and $_.CType -match "mux-fabric" -and $_.CType -notmatch "mux-fabric(.*)?[-]"} | % {
#--- Store current pipe variable to local variable ---#
$vif = $_
#--- Hash variable for storing current VIF data ---#
$vifHash = @{}
#--- The name of the current Path formatted to match the presentation in UCSM ---#
$vifHash.Name = "Path " + $_.SwitchId + '/' + ($_.Dn | Select-String -pattern "(?<=path[-]).*(?=[/])")[0].Matches.Value
#--- Gets peer port information filtered to the current path for adapter and fex host port ---#
$vifPeers = $paths | ? {$_.EpDn -match ($vif.EpDn | Select-String -pattern ".*(?=(.*[/]){2})").Matches.Value -and $_.Dn -match ($vif.Dn | Select-String -pattern ".*(?=(.*[/]){3})").Matches.Value -and $_.Dn -ne $vif.Dn}
#--- If Adapter PortId is greater than 1000 then format string as a port channel ---#
if($vifPeers[1].PeerPortId -gt 1000)
{
$vifHash.Adapter_Port = 'PC-' + $vifPeers[1].PeerPortId
}
#--- Else format in slot/port notation ---#
else
{
$vifHash.Adapter_Port = "$($vifPeers[1].PeerSlotId)/$($vifPeers[1].PeerPortId)"
}
#--- If FEX PortId is greater than 1000 then format string as a port channel ---#
if($vifPeers[0].PortId -gt 1000)
{
$vifHash.Fex_Host_Port = 'PC-' + $vifPeers[0].PortId
}
#--- Else format in chassis/slot/port notation ---#
else
{
$vifHash.Fex_Host_Port = "$($vifPeers[0].ChassisId)/$($vifPeers[0].SlotId)/$($vifPeers[0].PortId)"
}
#--- If Network PortId is greater than 1000 then format string as a port channel ---#
if($vif.PortId -gt 1000)
{
$vifHash.Fex_Network_Port = 'PC-' + $vif.PortId
}
#--- Else format in fabricId/slot/port notation ---#
else
{
$vifHash.Fex_Network_Port = $vif.PortId
}
#--- Server Port for current path as formatted in UCSM ---#
$vifHash.FI_Server_Port = "$($vif.SwitchId)/$($vif.PeerSlotId)/$($vif.PeerPortId)"
#--- Array variable for storing virtual circuit data ---#
$vifHash.Circuits = @()
#--- Iterate through all circuits for the current vif ---#
$circuits | ? {$_.Dn -cmatch ($vif.Dn | Select-String -pattern ".*(?<=[/])")[0].Matches.Value} | Select Id,vNic,OperBorderPortId,OperBorderSlotId,LinkState,SwitchId | % {
#--- Hash variable for storing current circuit data ---#
$vcHash = @{}
$vcHash.Name = 'Virtual Circuit ' + $_.Id
$vcHash.vNic = $_.vNic
$vcHash.Link_State = $_.LinkState
#--- Check if the current circuit is pinned to a PC uplink ---#
if($_.OperBorderPortId -gt 0 -and $_.OperBorderSlotId -eq 0)
{
$vcHash.FI_Uplink = "$($_.SwitchId)/PC - $($_.OperBorderPortId)"
}
#--- Check if the current circuit is unpinned ---#
elseif($_.OperBorderPortId -eq 0 -and $_.OperBorderSlotId -eq 0)
{
$vcHash.FI_Uplink = "unpinned"
}
#--- Assume that the circuit is pinned to a single uplink port ---#
else
{
$vcHash.FI_Uplink = "$($_.SwitchId)/$($_.OperBorderSlotId)/$($_.OperBorderPortId)"
}
#--- Add current circuit data to loop array variable ---#
$vifHash.Circuits += $vcHash
}
#--- Add vif data to blade hash ---#
$bladeHash.VIFs += $vifHash
}
#--- Get the configured boot definition of the current blade ---#
#--- Array variable for storing boot order data ---#
$bladeHash.Configured_Boot_Order = @()
#--- Iterate through all boot parameters for current blade ---#
$blade | Get-UcsBootDefinition | % {
#--- Store current pipe variable to local variable ---#
$policy = $_
#--- Hash variable for storing current boot data ---#
$bootHash = @{}
#--- Grab multiple boot policy data points from current policy ---#
($bootHash.Dn,$bootHash.BootMode,$bootHash.EnforceVnicName,$bootHash.Name,$bootHash.RebootOnUpdate,$bootHash.Owner) = $policy.Dn,$policy.BootMode,$policy.EnforceVnicName,$policy.Name,$policy.RebootOnUpdate,$policy.Owner
#--- Array variable for string boot policy entries ---#
$bootHash.Entries = @()
#--- Get all child objects of the current policy and sort by boot order ---#
$policy | Get-UcsChild | Sort-Object Order | % {
#--- Store current pipe variable to local variable ---#
$entry = $_
#===========================================================#
# Switch statement using the device type as the target #
# #
# Variable Definitions: #
# Level1 - VNIC, Order #
# Level2 - Type, VNIC Name #
# Level3 - Lun, Type, WWN #
#===========================================================#
Switch ($entry.Type)
{
#--- Matches either local media or SAN storage ---#
'storage' {
#--- Get child data of boot entry for more detailed information ---#
$entry | Get-UcsChild | Sort-Object Type | % {
#--- Hash variable for storing current boot entry data ---#
$entryHash = @{}
#--- Checks if current entry is a SAN target ---#
if($_.Rn -match "san")
{
#--- Grab Level1 data ---#
$entryHash.Level1 = $entry | Select-Object Type,Order
#--- Array for storing Level2 data ---#
$entryHash.Level2 = @()
#--- Hash variable for storing current san entry data ---#
$sanHash = @{}
$sanHash.Type = $_.Type
$sanHash.VnicName = $_.VnicName
#--- Array variable for storing Level3 data ---#
$sanHash.Level3 = @()
#--- Get Level3 data from child object ---#
$sanHash.Level3 += $_ | Get-UcsChild | Sort-Object Type | Select-Object Lun,Type,Wwn
#--- Add sanHash to Level2 array variable
$entryHash.Level2 += $sanHash
#--- Add current boot entry data to boot hash ---#
$bootHash.Entries += $entryHash
}
#--- Checks if current entry is a local storage target ---#
elseif($_.Rn -match "local-storage")
{
#--- Selects Level1 data ---#
$_ | Get-UcsChild | Sort-Object Order | % {
$entryHash = @{}
$entryHash.Level1 = $_ | Select-Object Type,Order
$bootHash.Entries += $entryHash
}
}
}
}
#--- Matches virtual media types ---#
'virtual-media' {
$entryHash = @{}
#--- Get Level1 data plus Access type to determine device type ---#
$entryHash.Level1 = $entry | Select-Object Type,Order,Access
if ($entryHash.Level1.Access -match 'read-only')
{
$entryHash.Level1.Type = 'CD/DVD'
}
else
{
$entryHash.Level1.Type = 'Floppy'
}
$bootHash.Entries += $entryHash
}
#--- Matches lan boot types ---#
'lan' {
$entryHash = @{}
$entryHash.Level1 = $entry | Select-Object Type,Order
$entryHash.Level2 = @()
$entryHash.Level2 += $entry | Get-UcsChild | Select-Object VnicName,Type
$bootHash.Entries += $entryHash
}
#--- Matches SAN and iSCSI boot types ---#
'san' {
$entryHash = @{}
#--- Grab Level1 data ---#
$entryHash.Level1 = $entry | Select-Object Type,Order
$entryHash.Level2 = @()
$entry | Get-UcsChild | Sort-Object Type | % {
#--- Hash variable for storing current san entry data ---#
$sanHash = @{}
#--- Grab Level2 Data ---#
$sanHash.Type = $_.Type
$sanHash.VnicName = $_.VnicName
#--- Array variable for storing Level3 data ---#
$sanHash.Level3 = @()
#--- Get Level3 data from child object ---#
$sanHash.Level3 += $_ | Get-UcsChild | Sort-Object Type | Select-Object Lun,Type,Wwn
#--- Add sanHash to Level2 array variable
$entryHash.Level2 += $sanHash
}
#--- Add current boot entry data to boot hash ---#
$bootHash.Entries += $entryHash
}
'iscsi' {
#--- Hash variable for storing iscsi boot entry data ---#
$entryHash = @{}
#--- Grab Level1 boot data ---#
$entryHash.Level1 = $entry | Select-Object Type,Order
#--- Array variable for storing Level2 boot data ---#
$entryHash.Level2 = @()
#--- Get all iSCSI Level2 data from child objects ---#
$entryHash.Level2 += $entry | Get-UcsChild | Sort-Object Type | Select-Object ISCSIVnicName,Type
#--- Add current boot entry data to boot hash ---#
$bootHash.Entries += $entryHash
}
}
}
#--- Sort all boot entries by Level1 Order ---#
$bootHash.Entries = $bootHash.Entries | Sort-Object {$_.Level1.Order}
#--- Store boot entries to configured boot order array ---#
$bladeHash.Configured_Boot_Order += $bootHash
}
#--- Grab actual boot order data from BIOS boot order table for current blade ---#
#--- Array variable for storing boot entries ---#
$bladeHash.Actual_Boot_Order = @()
#--- Iterate through all boot entries ---#
$blade | Get-UcsBiosUnit | Get-UcsBiosBOT | Get-UcsBiosBootDevGrp | Sort-Object Order | % {
#--- Store current pipe variable to local variable ---#
$entry = $_
#--- Hash variable for storing current entry data ---#
$bootHash = @{}
#--- Grab entry device type ---#
$bootHash.Descr = $entry.Descr
#--- Grab detailed information about current boot entry ---#
$bootHash.Entries = @()
$entry | Get-UcsBiosBootDev | % {
#--- Formats Entry string like UCSM presentation ---#
$bootHash.Entries += "($($_.Order)) $($_.Descr)"
}
#--- Add boot entry data to actual boot order array ---#
$bladeHash.Actual_Boot_Order += $bootHash
}
#--- Add current blade hash data to DomainHash variable ---#
$DomainHash.Inventory.Blades += $bladeHash
}
#--- End Blade Inventory Collection ---#
#--- Start Rack Inventory Collection ---#
#--- Set current job progress ---#
Write-Progress -Activity "Gathering Details on $domain" `
-Status "Rack Data" `
-PercentComplete 48 `
-Id 0
#--- Array variable for storing rack server data ---#
$DomainHash.Inventory.Rackmounts = @()
#--- Array variable for storing rack server adapter data ---#
$DomainHash.Inventory.Rackmount_Adapters = @()
#--- Iterate through each rackmount server and grab relevant data ---#
Get-UcsRackUnit -Ucs $handle | % {
#--- Store current pipe variable and store to local variable ---#
$rack = $_
#--- Hash variable for storing current rack server data ---#
$rackHash = @{}
$rackHash.Rack_Id = $rack.Id
$rackHash.Dn = $rack.Dn
#--- Get Model and Description common names and format the text ---#
($rackHash.Model,$rackHash.Model_Description) = Get-UcsEquipmentManufacturingDef -Ucs $handle -Filter "Sku -ieq $($rack.Model)" | Select Name,Description | % {($_.Name -replace "Cisco UCS ", ""),$_.Description}
$rackHash.Serial = $rack.Serial
$rackHash.Service_Profile = $rack.AssignedToDn
$rackHash.Uuid = $rack.Uuid
$rackHash.UsrLbl = $rack.UsrLbl
$rackHash.Name = $rack.Name
#--- If no service profile exists set profile name to "Unassociated" ---#
if(!($rackHash.Service_Profile))
{
$rackHash.Service_Profile = "Unassociated"
}
#--- Get child objects for pulling detailed information
$childTargets = $rack | Get-UcsChild | where {$_.Rn -ieq "bios" -or $_.Rn -ieq "mgmt" -or $_.Rn -ieq "board"} | get-ucschild
#--- Get rack CPU data ---#
$cpu = ($childTargets | where {$_.Rn -match "cpu" -and $_.Model -ne ""} | Select-Object -first 1).Model
#--- Get CPU common name and format text ---#
$rackHash.CPU = '(' + $rack.NumOfCpus + ')' + ($cpu.Substring(([regex]::match($cpu,'CPU ').Index) + ([regex]::match($cpu,'CPU ').Length))).Replace(" ","")
$rackHash.CPU_Cores = $rack.NumOfCores
$rackHash.CPU_Threads = $rack.NumOfThreads
#--- Format available memory in GB ---#
$rackHash.Memory = $rack.AvailableMemory/1024
$rackHash.Memory_Speed = $rack.MemorySpeed
$rackHash.BIOS = (($childTargets | where {$_.Type -eq "blade-bios"}).Version -replace ('(?!(.*[.]){2}).*',"")).TrimEnd('.')
$rackHash.CIMC = ($childTargets | where {$_.Type -eq "blade-controller" -and $_.Deployment -ieq "system"}).Version
#--- Iterate through each server adapter and grab detailed information ---#
foreach (${adapter} in ($rack | Get-UcsAdaptorUnit))
{
$adapterHash = @{}
$adapterHash.Rack_Id = $rack.Id
$adapterHash.Slot = ${adapter}.PciSlot
#--- Get common name of adapter model and format text ---#
$adapterHash.Model = (Get-UcsEquipmentManufacturingDef -Ucs $handle -Filter "Sku -cmatch $(${adapter}.Model)").Name -replace "Cisco UCS ", ""
$adapterHash.Serial = ${adapter}.Serial
$adapterHash.Running_FW = (${adapter} | Get-UcsMgmtController | Get-UcsFirmwareRunning -Deployment system).Version
#--- Add adapter data to Rackmount_Adapters array variable ---#
$DomainHash.Inventory.Rackmount_Adapters += $adapterHash
}
#--- Array variable for storing rack memory data ---#
$rackHash.Memory_Array = @()
#--- Iterage through all memory tied to current server and grab relevant data ---#
$memoryArray | ? Dn -cmatch $rack.Dn | Select Id,Location,Capacity,Clock | Sort-Object {($_.Id) -as [int]} | % {
#--- Hash variable for storing current memory data ---#
$memHash = @{}
$memHash.Name = "Memory " + $_.Id
$memHash.Location = $_.Location
#--- Format DIMM capacity in GB ---#
$memHash.Capacity = ($_.Capacity)/1024
$memHash.Clock = $_.Clock
$rackHash.Memory_Array += $memHash
}
#--- Array variable for storing local storage configuration data ---#
$rackHash.Storage = @()
#--- Iterate through each server storage controller and grab relevant data ---#
$rack | Get-UcsComputeBoard | Get-UcsStorageController | % {
#--- Store current pipe variable to local variable ---#
$controller = $_
#--- Hash variable for storing current storage controller data ---#
$controllerHash = @{}
#--- Grab relevant controller data and store to respective controllerHash variable ---#
$controllerHash.Id,$controllerHash.Vendor,$controllerHash.Revision,$controllerHash.RaidSupport,$controllerHash.PciAddr,$controllerHash.RebuildRate,$controllerHash.Model,$controllerHash.Serial,$controllerHash.ControllerStatus = $controller.Id,$controller.Vendor,$controller.HwRevision,$controller.RaidSupport,$controller.PciAddr,$controller.XtraProperty.RebuildRate,$controller.Model,$controller.Serial,$controller.XtraProperty.ControllerStatus
$controllerHash.Disk_Count = 0
#--- Array variable for storing controller disks ---#
$controllerHash.Disks = @()
$controller | Get-UcsStorageLocalDisk -Presence "equipped" | % {
#--- Store current pipe variable to local variable ---#
$disk = $_
#--- Hash variable for storing current disk data ---#
$diskHash = @{}
#--- Get common name of disk model and format text ---#
$equipmentDef = Get-UcsEquipmentManufacturingDef -Ucs $handle -Filter "OemPartNumber -ieq $($disk.Model)"
#--- Get detailed disk capability data ---#
$capabilities = Get-UcsEquipmentLocalDiskDef -Ucs $handle -Filter "Dn -cmatch $($disk.Model)"
$diskHash.Id = $disk.Id
$diskHash.Pid = $equipmentDef.Pid
$diskHash.Vendor = $disk.Vendor
$diskHash.Vid = $equipmentDef.Vid
$diskHash.Serial = $disk.Serial
$diskHash.Product_Name = $equipmentDef.Name
$diskHash.Drive_State = $disk.XtraProperty.DiskState
$diskHash.Power_State = $disk.XtraProperty.PowerState
#--- Format disk size to whole GB value ---#
$diskHash.Size = "{0:N2}" -f ($disk.Size/1024)
$diskHash.Link_Speed = $disk.XtraProperty.LinkSpeed
$diskHash.Blocks = $disk.NumberOfBlocks
$diskHash.Block_Size = $disk.BlockSize
$diskHash.Technology = $capabilities.Technology
$diskHash.Avg_Seek_Time = $capabilities.SeekAverageReadWrite
$diskHash.Track_To_Seek = $capabilities.SeekTrackToTrackReadWrite
$diskHash.Operability = $disk.Operability
$diskHash.Presence = $disk.Presence
$diskHash.Running_Version = ($disk | Get-UcsFirmwareRunning).Version
$controllerHash.Disk_Count += 1
#--- Add current disk hash to controller hash disk array ---#
$controllerHash.Disks += $diskHash
}
#--- Add controller hash variable to current rack hash storage array ---#
$rackHash.Storage += $controllerHash
}
#--- Array variable for storing VIF information for current rack ---#
$rackHash.VIFs = @()
#--- Grab all circuits that match the current rack DN and are active or link-down ---#
$circuits = Get-UcsDcxVc -Ucs $handle -Filter "Dn -cmatch $($rack.Dn) -and (OperState -cmatch active -or OperState -cmatch link-down)" | Select Dn,Id,OperBorderPortId,OperBorderSlotId,SwitchId,Vnic,LinkState
#--- Iterate through all paths of type "mux-fabric" for the current rack ---#
$paths | ? {$_.Dn -Match $rack.Dn -and $_.CType -match "mux-fabric" -and $_.CType -notmatch "mux-fabric(.*)?[-]"} | % {
#--- Store current pipe variable to local variable ---#
$vif = $_
#--- Hash variable for storing current VIF data ---#
$vifHash = @{}
#--- The name of the current Path formatted to match the presentation in UCSM ---#
$vifHash.Name = "Path " + $_.SwitchId + '/' + ($_.Dn | Select-String -pattern "(?<=path[-]).*(?=[/])")[0].Matches.Value
#--- Gets peer port information filtered to the current path for adapter and fex host port ---#
$vifPeers = $paths | ? {$_.EpDn -match ($vif.EpDn | Select-String -pattern ".*(?=(.*[/]){2})").Matches.Value -and $_.Dn -match ($vif.Dn | Select-String -pattern ".*(?=(.*[/]){3})").Matches.Value -and $_.Dn -ne $vif.Dn}
$vifHash.Adapter_Port = "$($vifPeers[1].PeerSlotId)/$($vifPeers[1].PeerPortId)"
$vifHash.Fex_Host_Port = "$($vifPeers[1].ChassisId)/$($vifPeers[1].SlotId)/$($vifPeers[1].PortId)"
$vifHash.Fex_Network_Port = $vifPeers[0].PortId
$vifHash.FI_Server_Port = "$($vif.SwitchId)/$($vif.PeerSlotId)/$($vif.PeerPortId)"
#--- Array variable for storing virtual circuit data ---#
$vifHash.Circuits = @()
#--- Iterate through all circuits for the current vif ---#
$circuits | ? {$_.Dn -cmatch ($vif.Dn | Select-String -pattern ".*(?<=[/])")[0].Matches.Value} | Select Id,vNic,OperBorderPortId,OperBorderSlotId,LinkState,SwitchId | % {
#--- Hash variable for storing current circuit data ---#
$vcHash = @{}
$vcHash.Name = 'Virtual Circuit ' + $_.Id
$vcHash.vNic = $_.vNic
$vcHash.Link_State = $_.LinkState
#--- Check if the current circuit is pinned to a PC uplink ---#
if($_.OperBorderPortId -gt 0 -and $_.OperBorderSlotId -eq 0)
{
$vcHash.FI_Uplink = "$($_.SwitchId)/PC - $($_.OperBorderPortId)"
}
#--- Check if the current circuit is unpinned ---#
elseif($_.OperBorderPortId -eq 0 -and $_.OperBorderSlotId -eq 0)
{
$vcHash.FI_Uplink = "unpinned"
}
#--- Assume that the circuit is pinned to a single uplink port ---#
else
{
$vcHash.FI_Uplink = "$($_.SwitchId)/$($_.OperBorderSlotId)/$($_.OperBorderPortId)"
}
$vifHash.Circuits += $vcHash
}
$rackHash.VIFs += $vifHash
}
#--- Get the configured boot definition of the current rack ---#
#--- Array variable for storing boot order data ---#
$rackHash.Configured_Boot_Order = @()
#--- Iterate through all boot parameters for current rack ---#
$rack | Get-UcsBootDefinition | % {
#--- Store current pipe variable to local variable ---#
$policy = $_
#--- Hash variable for storing current boot data ---#
$bootHash = @{}
#--- Grab multiple boot policy data points from current policy ---#
($bootHash.Dn,$bootHash.BootMode,$bootHash.EnforceVnicName,$bootHash.Name,$bootHash.RebootOnUpdate,$bootHash.Owner) = $policy.Dn,$policy.BootMode,$policy.EnforceVnicName,$policy.Name,$policy.RebootOnUpdate,$policy.Owner
#--- Array variable for string boot policy entries ---#
$bootHash.Entries = @()
#--- Get all child objects of the current policy and sort by boot order ---#
$policy | Get-UcsChild | Sort-Object Order | % {
#--- Store current pipe variable to local variable ---#
$entry = $_
#===========================================================#
# Switch statement using the device type as the target #
# #
# Variable Definitions: #
# Level1 - VNIC, Order #
# Level2 - Type, VNIC Name #
# Level3 - Lun, Type, WWN #
#===========================================================#
Switch ($entry.Type)
{
#--- Matches either local media or SAN storage ---#
'storage' {
#--- Get child data of boot entry for more detailed information ---#
$entry | Get-UcsChild | Sort-Object Type | % {
#--- Hash variable for storing current boot entry data ---#
$entryHash = @{}
#--- Checks if current entry is a SAN target ---#
if($_.Rn -match "san")
{
#--- Grab Level1 data ---#
$entryHash.Level1 = $entry | Select-Object Type,Order
#--- Array for storing Level2 data ---#
$entryHash.Level2 = @()
#--- Hash variable for storing current san entry data ---#
$sanHash = @{}
$sanHash.Type = $_.Type
$sanHash.VnicName = $_.VnicName
#--- Array variable for storing Level3 data ---#
$sanHash.Level3 = @()
#--- Get Level3 data from child object ---#
$sanHash.Level3 += $_ | Get-UcsChild | Sort-Object Type | Select-Object Lun,Type,Wwn
#--- Add sanHash to Level2 array variable
$entryHash.Level2 += $sanHash
#--- Add current boot entry data to boot hash ---#
$bootHash.Entries += $entryHash
}
#--- Checks if current entry is a local storage target ---#
elseif($_.Rn -match "local-storage")
{
#--- Selects Level1 data ---#
$_ | Get-UcsChild | Sort-Object Order | % {
$entryHash = @{}
$entryHash.Level1 = $_ | Select-Object Type,Order
$bootHash.Entries += $entryHash
}
}
}
}
#--- Matches virtual media types ---#
'virtual-media' {
$entryHash = @{}
#--- Get Level1 data plus Access type to determine device type ---#
$entryHash.Level1 = $entry | Select-Object Type,Order,Access
if ($entryHash.Level1.Access -match 'read-only')
{
$entryHash.Level1.Type = 'CD/DVD'
}
else
{
$entryHash.Level1.Type = 'floppy'
}
$bootHash.Entries += $entryHash
}
#--- Matches lan boot types ---#
'lan' {
$entryHash = @{}
$entryHash.Level1 = $entry | Select-Object Type,Order
$entryHash.Level2 = @()
$entryHash.Level2 += $entry | Get-UcsChild | Select-Object VnicName,Type
$bootHash.Entries += $entryHash
}
#--- Matches SAN and iSCSI boot types ---#
'san' {
$entryHash = @{}
#--- Grab Level1 data ---#
$entryHash.Level1 = $entry | Select-Object Type,Order
$entryHash.Level2 = @()
$entry | Get-UcsChild | Sort-Object Type | % {
#--- Hash variable for storing current san entry data ---#
$sanHash = @{}
#--- Grab Level2 Data ---#
$sanHash.Type = $_.Type
$sanHash.VnicName = $_.VnicName
#--- Array variable for storing Level3 data ---#
$sanHash.Level3 = @()
#--- Get Level3 data from child object ---#
$sanHash.Level3 += $_ | Get-UcsChild | Sort-Object Type | Select-Object Lun,Type,Wwn
#--- Add sanHash to Level2 array variable
$entryHash.Level2 += $sanHash
}
#--- Add current boot entry data to boot hash ---#
$bootHash.Entries += $entryHash
}
'iscsi' {
#--- Hash variable for storing iscsi boot entry data ---#
$entryHash = @{}
#--- Grab Level1 boot data ---#
$entryHash.Level1 = $entry | Select-Object Type,Order
#--- Array variable for storing Level2 boot data ---#
$entryHash.Level2 = @()
#--- Get all iSCSI Level2 data from child objects ---#
$entryHash.Level2 += $entry | Get-UcsChild | Sort-Object Type | Select-Object ISCSIVnicName,Type
#--- Add current boot entry data to boot hash ---#
$bootHash.Entries += $entryHash
}
}
}
#--- Sort all boot entries by Level1 Order ---#
$bootHash.Entries = $bootHash.Entries | Sort-Object {$_.Level1.Order}
#--- Store boot entries to configured boot order array ---#
$rackHash.Configured_Boot_Order += $bootHash
}
#--- Grab actual boot order data from BIOS boot order table for current rack ---#
#--- Array variable for storing boot entries ---#
$rackHash.Actual_Boot_Order = @()
#--- Iterate through all boot entries ---#
$rack | Get-UcsBiosUnit | Get-UcsBiosBOT | Get-UcsBiosBootDevGrp | Sort-Object Order | % {
#--- Store current pipe variable to local variable ---#
$entry = $_
#--- Hash variable for storing current entry data ---#
$bootHash = @{}
#--- Grab entry device type ---#
$bootHash.Descr = $entry.Descr
#--- Grab detailed information about current boot entry ---#
$bootHash.Entries = @()
$entry | Get-UcsBiosBootDev | % {
#--- Formats Entry string like UCSM presentation ---#
$bootHash.Entries += "($($_.Order)) $($_.Descr)"
}
#--- Add boot entry data to actual boot order array ---#
$rackHash.Actual_Boot_Order += $bootHash
}
#--- Add racmount server hash to Inventory array ---#
$DomainHash.Inventory.Rackmounts += $rackHash
}
#--- End Rack Inventory Collection ---#
#--- Start Policy Data Collection ---#
#--- Update job progress percent ---#
Write-Progress -Activity "Gathering Details on $domain" `
-Status "Policy Data Collection" `
-PercentComplete 60 `
-Id 0
#--- Hash variable for storing system policies ---#
<#
$DomainHash.Policies.SystemPolicies = @{}
#--- Grab DNS and NTP data ---#
$DomainHash.Policies.SystemPolicies.DNS = @()
$DomainHash.Policies.SystemPolicies.DNS += (Get-UcsDnsServer -Ucs $handle).Name
$DomainHash.Policies.SystemPolicies.NTP = @()
$DomainHash.Policies.SystemPolicies.NTP += (Get-UcsNtpServer -Ucs $handle).Name
#--- Get chassis discovery data for future use ---#
$Chassis_Discovery = Get-UcsChassisDiscoveryPolicy -Ucs $handle | Select Action,LinkAggregationPref
$DomainHash.Policies.SystemPolicies.Action = $Chassis_Discovery.Action
$DomainHash.Policies.SystemPolicies.Grouping = $Chassis_Discovery.LinkAggregationPref
$DomainHash.Policies.SystemPolicies.Power = (Get-UcsPowerControlPolicy -Ucs $handle | Select Redundancy).Redundancy
$DomainHash.Policies.SystemPolicies.Maint = (Get-UcsMaintenancePolicy -Name "default" -Ucs $handle | Select UptimeDisr).UptimeDisr
$DomainHash.Policies.SystemPolicies.Timezone = (Get-UcsTimezone).Timezone -replace '([(].*[)])', ""
#--- Maintenance Policies ---#
$DomainHash.Policies.Maintenance = @()
$DomainHash.Policies.Maintenance += Get-UcsMaintenancePolicy -Ucs $handle | Select-Object Name,Dn,UptimeDisr,Descr,SchedName
#--- Host Firmware Packages ---#
$DomainHash.Policies.FW_Packages = @()
$DomainHash.Policies.FW_Packages += Get-UcsFirmwareComputeHostPack -Ucs $handle | Select Name,BladeBundleVersion,RackBundleVersion
#--- LDAP Policy Data ---#
$DomainHash.Policies.LDAP_Providers = @()
$DomainHash.Policies.LDAP_Providers += Get-UcsLdapProvider -Ucs $handle | Select-Object Name,Rootdn,Basedn,Attribute
$mappingArray = @()
$DomainHash.Policies.LDAP_Mappings = @()
$mappingArray += Get-UcsLdapGroupMap -Ucs $handle
$mappingArray | % {
$mapHash = @{}
$mapHash.Name = $_.Name
$mapHash.Roles = ($_ | Get-UcsUserRole).Name
$mapHash.Locales = ($_ | Get-UcsUserLocale).Name
$DomainHash.Policies.LDAP_Mappings += $mapHash
}
#--- Boot Order Policies ---#
$DomainHash.Policies.Boot_Policies = @()
Get-UcsBootPolicy | % {
#--- Store current pipe variable to local variable ---#
$policy = $_
#--- Hash variable for storing current boot data ---#
$bootHash = @{}
#--- Grab multiple boot policy data points from current policy ---#
($bootHash.Dn,$bootHash.Description,$bootHash.BootMode,$bootHash.EnforceVnicName,$bootHash.Name,$bootHash.RebootOnUpdate,$bootHash.Owner) = $policy.Dn,$policy.Descr,$policy.BootMode,$policy.EnforceVnicName,$policy.Name,$policy.RebootOnUpdate,$policy.Owner
#--- Array variable for string boot policy entries ---#
$bootHash.Entries = @()
#--- Get all child objects of the current policy and sort by boot order ---#
$policy | Get-UcsChild | Sort-Object Order | % {
#--- Store current pipe variable to local variable ---#
$entry = $_
#===========================================================#
# Switch statement using the device type as the target #
# #
# Variable Definitions: #
# Level1 - VNIC, Order #
# Level2 - Type, VNIC Name #
# Level3 - Lun, Type, WWN #
#===========================================================#
Switch ($entry.Type)
{
#--- Matches either local media or SAN storage ---#
'storage' {
#--- Get child data of boot entry for more detailed information ---#
$entry | Get-UcsChild | Sort-Object Type | % {
#--- Hash variable for storing current boot entry data ---#
$entryHash = @{}
#--- Checks if current entry is a SAN target ---#
if($_.Rn -match "san")
{
#--- Grab Level1 data ---#
$entryHash.Level1 = $entry | Select-Object Type,Order
#--- Array for storing Level2 data ---#
$entryHash.Level2 = @()
#--- Hash variable for storing current san entry data ---#
$sanHash = @{}
$sanHash.Type = $_.Type
$sanHash.VnicName = $_.VnicName
#--- Array variable for storing Level3 data ---#
$sanHash.Level3 = @()
#--- Get Level3 data from child object ---#
$sanHash.Level3 += $_ | Get-UcsChild | Sort-Object Type | Select-Object Lun,Type,Wwn
#--- Add sanHash to Level2 array variable
$entryHash.Level2 += $sanHash
#--- Add current boot entry data to boot hash ---#
$bootHash.Entries += $entryHash
}
#--- Checks if current entry is a local storage target ---#
if($_.Rn -match "local-storage")
{
#--- Selects Level1 data ---#
$_ | Get-UcsChild | Sort-Object Order | % {
$entryHash = @{}
$entryHash.Level1 = $_ | Select-Object Type,Order
$bootHash.Entries += $entryHash
}
}
}
}
#--- Matches virtual media types ---#
'virtual-media' {
$entryHash = @{}
$entryHash.Level1 = $entry | Select-Object Type,Order,Access
if ($entryHash.Level1.Access -match 'read-only')
{
$entryHash.Level1.Type = 'CD/DVD'
}
else
{
$entryHash.Level1.Type = 'floppy'
}
$bootHash.Entries += $entryHash
}
#--- Matches lan boot types ---#
'lan' {
$entryHash = @{}
$entryHash.Level1 = $entry | Select-Object Type,Order
$entryHash.Level2 = @()
$entryHash.Level2 += $entry | Get-UcsChild | Select-Object VnicName,Type
$bootHash.Entries += $entryHash
}
#--- Matches SAN boot types ---#
'san' {
$entryHash = @{}
#--- Grab Level 1 Data ---#
$entryHash.Level1 = $entry | Select-Object Type,Order
#--- Array variable for Level 2 data ---#
$entryHash.Level2 = @()
#--- Iterate through each child object for Level 2 and 3 details ---#
$entry | Get-UcsChild | Sort-Object Type | % {
$sanHash = @{}
$sanHash.Type = $_.Type
$sanHash.VnicName = $_.VnicName
$sanHash.Level3 = @()
$sanHash.Level3 += $_ | Get-UcsChild | Sort-Object Type | Select-Object Lun,Type,Wwn
$entryHash.Level2 += $sanHash
}
#--- Add current boot entry data to boot hash ---#
$bootHash.Entries += $entryHash
}
#--- Matches ISCSI boot types ---#
'iscsi' {
#--- Hash variable for storing iscsi boot entry data ---#
$entryHash = @{}
#--- Grab Level1 boot data ---#
$entryHash.Level1 = $entry | Select-Object Type,Order
#--- Array variable for storing Level2 boot data ---#
$entryHash.Level2 = @()
#--- Get all iSCSI Level2 data from child objects ---#
$entryHash.Level2 += $entry | Get-UcsChild | Sort-Object Type | Select-Object ISCSIVnicName,Type
#--- Add current boot entry data to boot hash ---#
$bootHash.Entries += $entryHash
}
}
}
#--- Sort all boot entries by Level1 Order ---#
$bootHash.Entries = $bootHash.Entries | Sort-Object {$_.Level1.Order}
#--- Store boot entries to system boot policies array ---#
$DomainHash.Policies.Boot_Policies+= $bootHash
}
#--- End System Policies Collection ---#
#--- Start ID Pool Collection ---#
#--- External Mgmt IP Pool ---#
$DomainHash.Policies.Mgmt_IP_Pool = @{}
#--- Get the default external management pool ---#
$mgmtPool = Get-ucsippoolblock -Ucs $handle -Filter "Dn -cmatch ext-mgmt"
$DomainHash.Policies.Mgmt_IP_Pool.From = $mgmtPool.From
$DomainHash.Policies.Mgmt_IP_Pool.To = $mgmtPool.To
$parentPool = $mgmtPool | get-UcsParent
$DomainHash.Policies.Mgmt_IP_Pool.Size = $parentPool.Size
$DomainHash.Policies.Mgmt_IP_Pool.Assigned = $parentPool.Assigned
#--- Mgmt IP Allocation ---#
$DomainHash.Policies.Mgmt_IP_Allocation = @()
$parentPool | Get-UcsIpPoolPooled -Filter "Assigned -ieq yes" | Select AssignedToDn,Id,Subnet,DefGw | % {
$allocationHash = @{}
$allocationHash.Dn = $_.AssignedToDn -replace "/mgmt/*.*", ""
$allocationHash.IP = $_.Id
$allocationHash.Subnet = $_.Subnet
$allocationHash.GW = $_.DefGw
$DomainHash.Policies.Mgmt_IP_Allocation += $allocationHash
}
#--- UUID ---#
$DomainHash.Policies.UUID_Pools = @()
$DomainHash.Policies.UUID_Pools += Get-UcsUuidSuffixPool -Ucs $handle | Select-Object Dn,Name,AssignmentOrder,Prefix,Size,Assigned
$DomainHash.Policies.UUID_Assignments = @()
$DomainHash.Policies.UUID_Assignments += Get-UcsUuidpoolAddr -Ucs $handle -Assigned yes | select-object AssignedToDn,Id | sort-object -property AssignedToDn
#--- Server Pools ---#
$DomainHash.Policies.Server_Pools = @()
$DomainHash.Policies.Server_Pools += Get-UcsServerPool -Ucs $handle | Select-Object Dn,Name,Size,Assigned
$DomainHash.Policies.Server_Pool_Assignments = @()
$DomainHash.Policies.Server_Pool_Assignments += Get-UcsServerPoolAssignment -Ucs $handle | Select-Object Name,AssignedToDn
#--- End ID Pools Collection ---#
#>
#--- Start Service Profile data collection ---#
#--- Get Service Profiles by Template ---#
#--- Update current job progress ---#
Write-Progress -Activity "Gathering Details on $domain" `
-Status "Service Profile Collection" `
-PercentComplete 72 `
-Id 0
#--- Grab all Service Profiles ---#
$profiles = Get-UcsServiceProfile -Ucs $handle
#--- Grab all performance statistics for future use ---#
#$statistics = Get-UcsStatistics -Ucs $handle Yeah... we don't want statistics. They suck.
$statistics = $null
#--- Array variable for storing template data ---#
$templates = @()
#--- Grab all service profile templates ---#
$templates += ($profiles | ? {$_.Type -match "updating[-]template|initial[-]template"} | Select Name).Name
#--- Add an empty template entry for profiles not bound to a template ---#
$templates += ""
#--- Iterate through templates and grab configuration data ---#
#--- Hash variable to store data for current templateName ---#
<#
$DomainHash.Profiles[$templateName] = @{}
#--- Switch statement to format the template type ---#
switch (($profiles | ? {$_.Name -ieq "$templateName"}).Type)
{
"updating-template" {$DomainHash.Profiles[$templateName].Type = "Updating"}
"initial-template" {$DomainHash.Profiles[$templateName].Type = "Initial"}
default {$DomainHash.Profiles[$templateName].Type = "N/A"}
}
#--- Template Details - General Tab ---#
#--- Hash variable for storing general template data ---#
$DomainHash.Profiles[$templateName].General = @{}
$DomainHash.Profiles[$templateName].General.Name = $templateName
$DomainHash.Profiles[$templateName].General.Type = $DomainHash.Profiles[$templateName].Type
$DomainHash.Profiles[$templateName].General.Description = $template.Descr
$DomainHash.Profiles[$templateName].General.UUIDPool = $template.IdentPoolName
$DomainHash.Profiles[$templateName].General.Boot_Policy = $template.OperBootPolicyName
$DomainHash.Profiles[$templateName].General.PowerState = ($UcsServerPower | ?{$_.Dn -match $template.Dn}).State
$DomainHash.Profiles[$templateName].General.MgmtAccessPolicy = $template.ExtIPState
$DomainHash.Profiles[$templateName].General.Dn = $template.Dn
# This doesn't appear to return much, may need clean up later
$DomainHash.Profiles[$templateName].General.Server_Pool = $template | Get-UcsServerPoolAssignment | Select Name,Qualifier,RestrictMigration
$DomainHash.Profiles[$templateName].General.Maintenance_Policy = $UcsMaintenancePolicy |?{$_.dn -match $template.OperLocalDiskPolicyName} | Select Name,Dn,Descr,UptimeDisr
#--- Template Details - Storage Tab ---#
#--- Hash variable for storing storage template data ---#
$DomainHash.Profiles[$templateName].Storage = @{}
#--- Node WWN Configuration ---#
$fcNode = $UcsVnicFcNode | ?{$_.Dn -match $template.Dn}
#--- Grab VNIC connectivity ---#
$vnicConn = $UcsVnicConnDef | ?{$_.Dn -match $template.Dn}
$DomainHash.Profiles[$templateName].Storage.Nwwn = $fcNode.Addr
$DomainHash.Profiles[$templateName].Storage.Nwwn_Pool = $fcNode.IdentPoolName
$DomainHash.Profiles[$templateName].Storage.Local_Disk_Config = $UcsLocalDiskConfigPolicy | ?{$_.Dn -match $template.OperLocalDiskPolicyName} | Select Mode,ProtectConfig,XtraProperty
$DomainHash.Profiles[$templateName].Storage.Connectivity_Policy = $vnicConn.SanConnPolicyName
$DomainHash.Profiles[$templateName].Storage.Connectivity_Instance = $vnicConn.OperSanConnPolicyName
#--- Array variable for storing HBA data ---#
$DomainHash.Profiles[$templateName].Storage.Hbas = @()
$templateHBAs = $UcsVhba | ?{$_.Dn -match $template.Dn}
foreach ($templateHBA in $templateHBAs)
{
Write-Progress -Activity "Analyzing templateHBA $($templateHBA.pwwn)" `
-Status "templateHBA $($templateHBAs.IndexOf($templateHBA)) of $($templateHBAs.Count)" `
-PercentComplete $(($templateHBAs.IndexOf($templateHBA) / $templateHBAs.Count)*100) `
-Id 2 -ParentId 1
$hbaHash = @{}
$hbaHash.Name = $templateHBA.Name
$hbaHash.Pwwn = $templateHBA.IdentPoolName
$hbaHash.FabricId = $templateHBA.SwitchId
$hbaHash.Desired_Order = $templateHBA.Order
$hbaHash.Actual_Order = $templateHBA.OperOrder
$hbaHash.Desired_Placement = $templateHBA.AdminVcon
$hbaHash.Actual_Placement = $templateHBA.OperVcon
$hbaHash.Vsan = ($templateHBA | Get-UcsChild | Select Name).Name
$DomainHash.Profiles[$templateName].Storage.Hbas += $hbaHash
}
Write-Progress -Activity "." -Complete -Id 2
#--- Template Details - Network Tab ---#
#--- Hash variable for storing template network configuration ---#
$DomainHash.Profiles[$templateName].Network = @{}
#--- Lan Connectivity Policy ---#
$DomainHash.Profiles[$templateName].Network.Connectivity_Policy = $vnicConn.LanConnPolicyName
$DomainHash.Profiles[$templateName].Network.DynamicVnic_Policy = $template.DynamicConPolicyName
#--- Array variable for storing ---#
$DomainHash.Profiles[$templateName].Network.Nics = @()
#--- Iterate through each NIC and grab configuration details ---#
$templateNics = $UcsVnic | ?{$_.Dn -match $template.Dn}
foreach ($templateNic in $templateNics)
{
Write-Progress -Activity "Analyzing Template NIC $($templateNic.name)" `
-Status "Template NIC $($templateNics.IndexOf($templateNic)) of $($templateNics.Count)" `
-PercentComplete $(($templateNics.IndexOf($templateNic) / $templateNics.Count)*100) `
-Id 2 -ParentId 1
$nicHash = @{}
$nicHash.Name = $templateNic.Name
$nicHash.Mac_Address = $templateNic.Addr
$nicHash.Desired_Order = $templateNic.Order
$nicHash.Actual_Order = $templateNic.OperOrder
$nicHash.Fabric_Id = $templateNic.SwitchId
$nicHash.Desired_Placement = $templateNic.AdminVcon
$nicHash.Actual_Placement = $templateNic.OperVcon
$nicHash.Adaptor_Profile = $templateNic.AdaptorProfileName
$nicHash.Control_Policy = $templateNic.NwCtrlPolicyName
#--- Array for storing VLANs ---#
$nicHash.Vlans = @()
#--- Grab all VLANs ---#
$nicHash.Vlans += $templateNic | Get-UcsChild -ClassId VnicEtherIf | Select OperVnetName,Vnet,DefaultNet | Sort-Object {($_.Vnet) -as [int]}
$DomainHash.Profiles[$templateName].Network.Nics += $nicHash
}
Write-Progress -Activity "." -Complete -Id 2
#--- Template Details - Policies Tab ---#
#--- Hash variable for storing template Policy configuration data ---#
$DomainHash.Profiles[$templateName].Policies = @{}
$DomainHash.Profiles[$templateName].Policies.Bios = $template.BiosProfileName
$DomainHash.Profiles[$templateName].Policies.Fw = $template.HostFwPolicyName
$DomainHash.Profiles[$templateName].Policies.Ipmi = $template.MgmtAccessPolicyName
$DomainHash.Profiles[$templateName].Policies.Power = $template.PowerPolicyName
$DomainHash.Profiles[$templateName].Policies.Scrub = $template.ScrubPolicyName
$DomainHash.Profiles[$templateName].Policies.Sol = $template.SolPolicyName
$DomainHash.Profiles[$templateName].Policies.Stats = $template.StatsPolicyName
#--- Service Profile Instances ---#
#--- Array variable for storing profiles tied to current template name ---#
$DomainHash.Profiles[$templateName].Profiles = @()
#--- Iterate through all profiles tied to the current template name ---#
$sps = $profiles | ? {$_.SrcTemplName -ieq "$profileCheck" -and $_.Type -ieq "instance"}
foreach ($sp in $sps)
{
Write-Progress -Activity "Analyzing SP $($sp.dn)" `
-Status "SP $($sps.IndexOf($sp)) of $($sps.Count)" `
-PercentComplete $(($sps.IndexOf($sp) / $sps.Count)*100) `
-Id 2 -ParentId 1
#--- Store current pipe variable to local variable ---#
#--- Hash variable for storing current profile configuration data ---#
$profileHash = @{}
$profileHash.Dn = $sp.Dn
$profileHash.Service_Profile = $sp.Name
$profileHash.UsrLbl = $sp.UsrLbl
$profileHash.Assigned_Server = $sp.PnDn
$profileHash.Assoc_State = $sp.AssocState
$profileHash.Maint_Policy = $sp.MaintPolicyName
$profileHash.Maint_PolicyInstance = $sp.OperMaintPolicyName
$profileHash.FW_Policy = $sp.HostFwPolicyName
$profileHash.BIOS_Policy = $sp.BiosProfileName
$profileHash.Boot_Policy = $sp.OperBootPolicyName
#--- Service Profile Details - General Tab ---#
#--- Hash variable for storing general profile configuration data ---#
$profileHash.General = @{}
$profileHash.General.Name = $sp.Name
$profileHash.General.Overall_Status = $sp.operState
$profileHash.General.AssignState = $sp.AssignState
$profileHash.General.AssocState = $sp.AssocState
$profileHash.General.Power_State = ($sp | Get-UcsChild -ClassId LsPower | Select State).State
$profileHash.General.UserLabel = $sp.UsrLbl
$profileHash.General.Descr = $sp.Descr
$profileHash.General.Owner = $sp.PolicyOwner
$profileHash.General.Uuid = $sp.Uuid
$profileHash.General.UuidPool = $sp.OperIdentPoolName
$profileHash.General.Associated_Server = $sp.PnDn
$profileHash.General.Template_Name = $templateName
$profileHash.General.Template_Instance = $sp.OperSrcTemplName
$profileHash.General.Assignment = @{}
$pool = $UcsServerPoolAssignment | ?{$_.Dn -match $sp.Dn}
if($pool.Count -gt 0)
{
$profileHash.General.Assignment.Server_Pool = $pool.Name
$profileHash.General.Assignment.Qualifier = $pool.Qualifier
$profileHash.General.Assignment.Restrict_Migration = $pool.RestrictMigration
}
else
{
$lsServer = $UcsLsBinding | ?{$_.Dn -match $sp.Dn}
$profileHash.General.Assignment.Server = $lsServer.AssignedToDn
$profileHash.General.Assignment.Restrict_Migration = $lsServer.RestrictMigration
}
#--- Service Profile Details - Storage Tab ---#
$profileHash.Storage = @{}
$fcNode = $UcsVnicFcNode | ?{$_.Dn -match $sp.Dn}
$vnicConn = $UcsVnicConnDef | ?{$_.Dn -match $sp.Dn}
$profileHash.Storage.Nwwn = $fcNode.Addr
$profileHash.Storage.Nwwn_Pool = $fcNode.IdentPoolName
$profileHash.Storage.Local_Disk_Config = $UcsLocalDiskConfigPolicy | ?{$_.Dn -match $sp.OperLocalDiskPolicyName} | Select Mode,ProtectConfig,XtraProperty
$profileHash.Storage.Connectivity_Policy = $vnicConn.SanConnPolicyName
$profileHash.Storage.Connectivity_Instance = $vnicConn.OperSanConnPolicyName
#--- Array variable for storing HBA configuration data ---#
$profileHash.Storage.Hbas = @()
#--- Iterate through each HBA interface
$spVhbas = $UcsVhba |?{$_.Dn -match $sp.Dn} | Sort-Object OperVcon,OperOrder
foreach ($spVhba in $spVhbas)
{
Write-Progress -Activity "Analyzing SP Vhbas $($spVhba.name)" `
-Status "SP Vhba $($spVhbas.IndexOf($spVhba)) of $($spVhbas.Count)" `
-PercentComplete $(($spVhbas.IndexOf($spVhba) / $spVhbas.Count)*100) `
-Id 3 -ParentId 2
$hbaHash = @{}
$hbaHash.Name = $spVhba.Name
$hbaHash.Pwwn = $spVhba.Addr
$hbaHash.FabricId = $spVhba.SwitchId
$hbaHash.Desired_Order = $spVhba.Order
$hbaHash.Actual_Order = $spVhba.OperOrder
$hbaHash.Desired_Placement = $spVhba.AdminVcon
$hbaHash.Actual_Placement = $spVhba.OperVcon
$hbaHash.EquipmentDn = $spVhba.EquipmentDn
$hbaHash.Vsan = ($spVhba | Get-UcsChild | Select OperVnetName).OperVnetName
$profileHash.Storage.Hbas += $hbaHash
}
Write-Progress -Activity "." -Complete -Id 3
#--- Service Profile Details - Network Tab ---#
$profileHash.Network = @{}
$profileHash.Network.Connectivity_Policy = $vnicConn.LanConnPolicyName
#--- Array variable for storing NIC configuration data ---#
$profileHash.Network.Nics = @()
#--- Iterate through each vNIC and grab configuration data ---#
foreach ($spVnic in $UcsVnic)
{
Write-Progress -Activity "Analyzing SPVnic $($spVnic.name)" `
-Status "SPVnic $($UcsVnic.IndexOf($spVnic)) of $($UcsVnic.Count)" `
-PercentComplete $(($UcsVnic.IndexOf($spVnic) / $UcsVnic.Count)*100) `
-Id 4 -ParentId 2
$nicHash = @{}
$nicHash.Name = $spVnic.Name
$nicHash.Mac_Address = $spVnic.Addr
$nicHash.Desired_Order = $spVnic.Order
$nicHash.Actual_Order = $spVnic.OperOrder
$nicHash.Fabric_Id = $spVnic.SwitchId
$nicHash.Desired_Placement = $spVnic.AdminVcon
$nicHash.Actual_Placement = $spVnic.OperVcon
$nicHash.Mtu = $spVnic.Mtu
$nicHash.EquipmentDn = $spVnic.EquipmentDn
$nicHash.Adaptor_Profile = $spVnic.AdaptorProfileName
$nicHash.Control_Policy = $spVnic.NwCtrlPolicyName
$nicHash.Qos = $spVnic.OperQosPolicyName
$nicHash.Vlans = @()
$nicHash.Vlans += $spVnic | Get-UcsChild -ClassId VnicEtherIf | Select OperVnetName,Vnet,DefaultNet | Sort-Object {($_.Vnet) -as [int]}
$profileHash.Network.Nics += $nicHash
}
#--- Service Profile Policies ---#
$profileHash.Policies = @{}
$profileHash.Policies.Bios = $sp.BiosProfileName
$profileHash.Policies.Fw = $sp.HostFwPolicyName
$profileHash.Policies.Ipmi = $sp.MgmtAccessPolicyName
$profileHash.Policies.Power = $sp.PowerPolicyName
$profileHash.Policies.Scrub = $sp.ScrubPolicyName
$profileHash.Policies.Sol = $sp.SolPolicyName
$profileHash.Policies.Stats = $sp.StatsPolicyName
#--- Add current profile to template profile array ---#
$DomainHash.Profiles[$templateName].Profiles += $profileHash
}
Write-Progress -Activity "." -Complete -Id 2
}
Write-Progress -Activity "." -Complete -Id 1
#--- End Service Profile Collection ---#
#>
#--- Start LAN Configuration ---#
#--- Get the collection time interval for port performance ---#
$DomainHash.Collection = @{}
$interval = (Get-UcsCollectionPolicy -Name "port" | Select CollectionInterval).CollectionInterval
#--- Normalize collection interval to seconds ---#
Switch -wildcard (($interval -split '[0-9]')[-1])
{
"minute*" { $DomainHash.Collection.Port = ((($interval -split '[a-z]')[0]) -as [int]) * 60 }
"second*" { $DomainHash.Collection.Port = ((($interval -split '[a-z]')[0]) -as [int]) }
}
#--- Get Event List ---#
#--- Update current job progress ---#
Write-Progress -Activity "Gathering Details on $domain" `
-Status "Event Data" `
-PercentComplete 84 `
-Id 0
#--- Grab faults of critical, major, minor, and warning severity sorted by severity ---#
$faultList = Get-UcsFault -Ucs $handle -Filter 'Severity -cmatch "critical|major|minor|warning"' | Sort-Object -Property Ucs,Severity | Select-Object Ucs,Severity,Created,Descr,dn
if($faultList)
{
#--- Iterate through each fault and grab information ---#
foreach ($fault in $faultList)
{
$faultHash = @{}
$faultHash.Severity = $fault.Severity;
$faultHash.Descr = $fault.Descr
$faultHash.Dn = $fault.Dn
$faultHash.Date = $fault.Created
$DomainHash.Faults += $faultHash
}
}
#--- Update current job progress ---#
Write-Progress -Activity "Gathering Details on $domain" `
-Status "Finishing Data gathering" `
-PercentComplete 96 `
-Id 0
Complete-UcsTransaction -Ucs $handle
$UcsDomain = $handle.Ucs
#--- Add current Domain data to global process Hash ---#
#--- Disconnect from current UCS domain ---#
Disconnect-Ucs -Ucs $handle
$DomainHash
Write-Progress "." -Complete -Id 0
}
$UcsDump = @{}
foreach ($ucsVip in $ucsVips)
{
Disconnect-Ucs
$handle = Connect-Ucs $ucsVip -Credential $cred
$myUCSMName = $handle.Ucs
if ($UcsDump.Keys -notcontains $myUCSMName)
{
$UcsDump["$myUCSMName"] = @{}
$output = Get-UcsData -domain $ucsVip -creds $cred
$UcsDump["$myUCSMName"] = $output
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment