Scripts/Get-PCProcessor.ps1
Function Get-PCProcessor { <# .SYNOPSIS Get processor information .DESCRIPTION Get processor information .PARAMETER ComputerName The target computer name .EXAMPLE Get-PCProcessor -ComputerName LabPC2024 .NOTES N/A .LINK N/A #> [CmdletBinding ()] Param ( [Parameter (Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True, HelpMessage = 'Enter computer name' ) ] [String[]]$ComputerName ) BEGIN { $CPUAvailability = @{ '1' = 'Other' '2' = 'Unknown' '3' = 'Running/Full power' '4' = 'Warning' '5' = 'In test' '6' = 'Not applicable' '7' = 'Power off' '8' = 'Off line' '9' = 'Off duty' '10' = 'Degraded' '11' = 'Not installed' '12' = 'Install error' '13' = 'Power save/Unknown' '14' = 'Power save/Low power mode' '15' = 'Power save/Standby' '16' = 'Power cycle' '17' = 'Power save/Warning' '18' = 'Paused' '19' = 'Not ready' '20' = 'Not configured' '21' = 'Quiet' } $CPUStatus = @{ '0' = 'Unknown' '1' = 'Enabled' '2' = 'Disabled by user via BIOS setup' '3' = 'CPU disabled by BIOS (POST error)' '4' = 'Idle' '5' = 'Reserved' '6' = 'Reserved' '7' = 'Other' } $CPUType = @{ '1' = 'Other' '2' = 'Unknown' '3' = 'Central processor' '4' = 'Math processor' '5' = 'DSP processor' '6' = 'Video processor' } $CPUArchitecture = @{ '0' = 'x86' '1' = 'MIPS' '2' = 'Alpha' '3' = 'PowerPC' '5' = 'ARM' '6' = 'ia64' '9' = 'x64' } Function Show-Output ($Computer, $Values, $Status) { [PSCustomObject]@{ ComputerName = $Computer Caption = $Values.Caption DeviceID = $Values.DeviceID Manufacturer = $Values.Manufacturer MaxClockSpeed = "$($Values.MaxClockSpeed / 1000)$(' GHz')" Name = $Values.Name SocketDesignation = $Values.SocketDesignation Availability = $CPUAvailability["$($Values.Availability)"] AddressWidth = $Values.AddressWidth DataWidth = $Values.DataWidth L2CacheSize = $Values.L2CacheSize L2CacheSpeed = $Values.L2CacheSpeed PowerManagementSupported = $Values.PowerManagementSupported ProcessorType = $CPUType["$($Values.ProcessorType)"] Revision = $Values.Revision CPUStatus = $CPUStatus["$($Values.CPUStatus)"] Architecture = $CPUArchitecture["$($Values.Architecture)"] NumberOfCores = $Values.NumberOfCores NumberOfEnabledCore = $Values.NumberOfEnabledCore NumberOfLogicalProcessors = $Values.NumberOfLogicalProcessors ThreadCount = $Values.ThreadCount ProcessorID = $Values.ProcessorId VirtualizationFirmwareEnabled = $Values.VirtualizationFirmwareEnabled VMMonitorModeExtensions = $Values.VMMonitorModeExtensions Status = $Status } } } PROCESS { ForEach ($Computer In $ComputerName) { If (Test-Connection -ComputerName $Computer -Count 1 -Quiet) { Try { $Data = Get-WmiObject Win32_Processor -ComputerName $Computer | Select-Object * ForEach ($Item In $Data) { Show-Output $Computer.ToUpper() $Item 'Ok' } } Catch { Show-Output $Computer.ToUpper() $Null $PSItem.Exception.Message } } Else { Show-Output $Computer.ToUpper() $Null 'Unreachable' } } } END {} } |