private/_GetSysInfo.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function _GetSysInfo {
    [cmdletbinding()]
    Param(
        [Microsoft.Management.Infrastructure.CimSession]$Cimsession
    )
    Write-Verbose "[$($CimSession.ComputerName)] - Gathering System information"
    $CS = Get-CimInstance -CimSession $CimSession -ClassName Win32_ComputerSystem -Property Manufacturer, Model, SystemType, NumberOfProcessors, NumberOfLogicalProcessors, TotalPhysicalMemory, Domain, DomainRole -ErrorAction Stop
    $Enclosure = Get-CimInstance -CimSession $CimSession -ClassName Win32_SystemEnclosure -Property SerialNumber, ChassisTypes, Description
    $BIOS = Get-CimInstance -CimSession $CimSession -ClassName Win32_Bios -Property Name, Manufacturer, SerialNumber, SMBIOSBIOSVersion
    [PSCustomObject]@{
        PSTypeName                = 'PSP.Inventory.SystemInfo'
        ComputerName              = $Cimsession.ComputerName
        Domain                    = $CS.Domain
        DomainRole                = (Convert-DomainRole $CS.DomainRole)
        Manufacturer              = $CS.Manufacturer
        Model                     = $CS.Model
        SystemType                = $CS.SystemType
        State                     = if ($CS.Manufacturer -match "Hyper|Citrix|VMWare|virtual|Microsoft") {'Virtual'}else {'Physical'}
        SerialNumber              = $Enclosure.SerialNumber
        ChassisType               = (Convert-ChassisType $Enclosure.ChassisTypes)
        Description               = $Enclosure.Description
        NumberofCores             = $CS.NumberOfProcessors
        NumberOfLogicalProcessors = $CS.NumberOfLogicalProcessors
        TotalPhysicalMemoryGB     = ([math]::round(($CS.TotalPhysicalMemory / 1GB), 0))
        BIOSManufacturer          = $BIOS.Manufacturer
        BIOSName                  = $BIOS.Name
        BIOSSerialNumber          = $BIOS.SerialNumber
        BIOSVersion               = $BIOS.SMBIOSBIOSVersion
        InventoryDate             = (Get-Date)
    }
}