Hardware Autogenerated Variables
This page will cover several hardware variables that are autogenerated at the start of the task sequence, which you can then use for PowerShell scripts and conditions.
The DeployR gather process is based on the similar gather process used in MDT, but then updated for PSD (PowerShell Deploy), which is a project that was sponsored by 2Pint. You can take a look at it here for the specifics: C:\Program Files\2Pint Software\DeployR\Client\ContentStore\LocalGather\1.0\PSDGather.psm1
Below is a list of the variables created, with additional details
Chassis
Description: This will return the Chassis type based on the system enclosure and create the following additional variables;
IsDeskop
IsLaptop
IsServer
IsSFF
IsTablet
WMI: ClassName = Win32_SystemEnclosure
Returned Values:
Laptop [8,9,10,11,12,14,18,21]
Desktop [3,4,5,6,7,15,16]
Server [23]
Small Form Factor [34,35,36]
Tablet [13,31,32,30]
PowerShell Code:
$LocalInfo = @{}
$LocalInfo['IsDesktop'] = "False"
$LocalInfo['IsLaptop'] = "False"
$LocalInfo['IsServer'] = "False"
$LocalInfo['IsSFF'] = "False"
$LocalInfo['IsTablet'] = "False"
Get-CimInstance -ClassName Win32_SystemEnclosure | ForEach-Object {
if ($_.ChassisTypes[0] -in "8", "9", "10", "11", "12", "14", "18", "21") { $LocalInfo['IsLaptop'] = "True"; $LocalInfo['Chassis'] = "Laptop"}
if ($_.ChassisTypes[0] -in "3", "4", "5", "6", "7", "15", "16") { $LocalInfo['IsDesktop'] = "True"; $LocalInfo['Chassis'] = "Desktop"}
if ($_.ChassisTypes[0] -in "23") { $LocalInfo['IsServer'] = "True"; $LocalInfo['Chassis'] = "Server"}
if ($_.ChassisTypes[0] -in "34", "35", "36") { $LocalInfo['IsSFF'] = "True"; $LocalInfo['Chassis'] = "Small Form Factor"}
if ($_.ChassisTypes[0] -in "13", "31", "32", "30") {$LocalInfo['IsTablet'] = "True"; $LocalInfo['Chassis'] = "Tablet"}
}
PS C:\WINDOWS\system32> $LocalInfo
Name Value
---- -----
IsLaptop True
Chassis Laptop
IsDesktop False
IsSFF False
IsServer False
IsTablet False
MacAddress
Description: Lists all MAC addresses of the device, can be several
WMI: Win32_NetworkAdapterConfiguration
Returned Values: MAC Address strings
PowerShell Code:
$macList = @()
Get-CimInstance -ClassName Win32_NetworkAdapterConfiguration -Filter "IPEnabled = 1" | ForEach-Object {
$_.MacAddress | ForEach-Object { $macList += $_ }
}
PS C:\WINDOWS\system32> $macList
58:1C:F8:23:3C:0A
E0:73:E7:66:3F:A7
IPAddress
Description: Lists all IP addresses of the device, can be several
WMI: Win32_NetworkAdapterConfiguration
Returned Values: IP Address strings
PowerShell Code:
$ipList = @()
Get-CimInstance -ClassName Win32_NetworkAdapterConfiguration -Filter "IPEnabled = 1" | ForEach-Object {
$_.IPAddress | ForEach-Object { $ipList += $_ }
}
PS C:\WINDOWS\system32> $ipList
192.168.20.162
fe80::b2f6:4d89:f447:4ee3
169.254.141.136
fe80::87c2:d75a:288e:8da1
DefaultGateway
Description: Is the default gateway IP Address of the machine
WMI: Win32_NetworkAdapterConfiguration
Returned Values: IP Address of gateway in string
PowerShell Code:
$gwList = @()
Get-CimInstance -ClassName Win32_NetworkAdapterConfiguration -Filter "IPEnabled = 1" | ForEach-Object {
if ($_.DefaultIPGateway) {
$_.DefaultIPGateway | ForEach-Object { $gwList += $_ }
}
}
PS C:\WINDOWS\system32> $gwList
192.168.20.1
OSVersion
Description: the OS version of the OS currently running
Registry: HKLM:System\CurrentControlSet\Control\MiniNT
Returned Values: WinPE, Other
PowerShell Code:
$LocalInfo = @{}
if (Test-Path HKLM:System\CurrentControlSet\Control\MiniNT) {
$LocalInfo['OSVersion'] = "WinPE"
}
else {
$LocalInfo['OSVersion'] = "Other"
}
PS C:\WINDOWS\system32> $LocalInfo
Name Value
---- -----
OSVersion Other
OSCurrentVersion
Description: provides the Operating System's current version
WMI: Win32_OperatingSystem
Returned Values: OS Version Number, ex:
10.0.26100
10.0.22631
10.0.19045
PowerShell Code:
PS C:\WINDOWS\system32> (Get-CimInstance -ClassName Win32_OperatingSystem).Version
10.0.26220
OSCurrentBuild
Description: provides the Operating System's build version
WMI: Win32_OperatingSystem
Returned Values: OS Build Number, ex:
26100
22631
19045
PowerShell Code:
PS C:\WINDOWS\system32> (Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber
26100
Serial Number
Description: provides the serial number of the device
WMI: Win32_BIOS
Returned Values: serial number string
PowerShell Code:
PS C:\WINDOWS\system32> (Get-CimInstance -ClassName Win32_BIOS).SerialNumber
5CG3160H2Z
Architecture
Description: provides the architechture of the processor
PowerShell: $env:PROCESSOR_ARCHITEW6432 or $env:PROCESSOR_ARCHITECTURE
Returned Values: x64, ARM64
PowerShell Code:
$LocalInfo = @{}
if ($env:PROCESSOR_ARCHITEW6432) {
if ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64") {
$LocalInfo['Architecture'] = "x64"
}
else {
$LocalInfo['Architecture'] = $env:PROCESSOR_ARCHITEW6432.ToUpper()
}
}
else {
if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") {
$LocalInfo['Architecture'] = "x64"
}
else {
$LocalInfo['Architecture'] = $env:PROCESSOR_ARCHITECTURE.ToUpper()
}
}
PS C:\WINDOWS\system32> $LocalInfo
Name Value
---- -----
Architecture x64
ProcessorSpeed
Description: provides the max clock speed of the processor
WMI: Win32_Processor
Returned Values: Number relateing to max clock speed of processor
PowerShell Code:
PS C:\WINDOWS\system32> (Get-CimInstance -ClassName Win32_Processor).MaxClockSpeed
2600
SupportsSLAT
Description: provides details about the Second Level Address Translation Extensions of the processor
WMI: Win32_Processor
Returned Values: True / False
PowerShell Code:
PS C:\WINDOWS\system32> (Get-CimInstance -ClassName Win32_Processor).SecondLevelAddressTranslationExtensions
False
Memory
Description: provides a number of calculated memory in MB
WMI: Win32_ComputerSystem
Returned Values: Number corrisponding to memory
This will not equal exactly the GB you're expecting. If you have "8GB" of RAM in your device, this returned value will often come in a bit under that number, so if you are creating your own scripts with memory requirements, and you want a machine to have "8GB" of RAM, you should give a 1 GB buffer in your script.
PowerShell Code
PS C:\WINDOWS\system32> (Get-CimInstance -ClassName Win32_ComputerSystem).TotalPhysicalMemory / 1024 / 1024
65168.2890625
PowerShell Example for GB for reference: (comes in just under the 64 that I expect)
PS C:\WINDOWS\system32> (Get-CimInstance -ClassName Win32_ComputerSystem).TotalPhysicalMemory / 1024 / 1024 / 1024
63.6409072875977
Manufacturer | Make | Model
Description: provides the details of the device from the OEM, grabbing the info from a couple locations if requried.
WMI: Win32_ComputerSystem & Win32_BaseBoard
Returned Values: string values that correspond to details about the device's OEM information
PowerShell Code:
$LocalInfo = @{}
Get-CimInstance -ClassName Win32_ComputerSystem | ForEach-Object {
$LocalInfo['Manufacturer'] = $_.Manufacturer.Trim()
$LocalInfo['Make'] = $_.Manufacturer.Trim()
$LocalInfo['Model'] = $_.Model.Trim()
}
if ($LocalInfo['Make'] -eq "") {
$Make = (Get-CimInstance -ClassName Win32_BaseBoard | Select-Object -ExpandProperty Manufacturer).Trim()
$LocalInfo['Make'] = $Make
$LocalInfo['Manufacturer'] = $Make
}
if ($LocalInfo['Model'] -eq "") {
$LocalInfo['Model'] = (Get-CimInstance -ClassName Win32_BaseBoard | Select-Object -ExpandProperty Product).Trim()
}
PS C:\WINDOWS\system32> $LocalInfo
Name Value
---- -----
Make HP
Manufacturer HP
Model HP ZBook Studio 16 inch G10 Mobile Workstation PC
UUID
Description: Universal Identifier number
WMI: Win32_ComputerSystemProduct
Returned Values: GUID String
PowerShell Code:
PS C:\WINDOWS\system32> (Get-CimInstance -ClassName Win32_ComputerSystemProduct).UUID.Trim()
B5999BAA-4FA3-4EBD-B109-EF39AF8892AA
CSPVersion
Description: provides the Chassis System Product Version set by the OEM
WMI: Win32_ComputerSystemProduct
Returned Values: Sting Value of Item(s) created by OEM
PowerShell Code:
PS C:\WINDOWS\system32> (Get-CimInstance -ClassName Win32_ComputerSystemProduct).Version.Trim()
SBKPF,SBKPFV2
BaseboardProduct
Description: provides the Baseboard Product value created by OEM
WMI: MS_SystemInformation
Returned Values: string, varies widely based on OEM
PowerShell Code:
PS C:\WINDOWS\system32> (Get-CimInstance -ClassName MS_SystemInformation -NameSpace root\WMI).BaseBoardProduct.Trim()
8B8F
Product
Description: provides the Baseboard Product value created by OEM
WMI: Win32_BaseBoard
Returned Values: string, varies widely based on OEM. HP uses this for their OEM lookups
PowerShell Code:
PS C:\WINDOWS\system32> (Get-CimInstance -ClassName Win32_BaseBoard).Product.trim()
8B8F
SystemSku
Description: provides the System SKU value created by OEM
WMI: MS_SystemInformation
Returned Values: string, varies widely based on OEM. MS Surface & Dell uses this for their OEM lookups
PowerShell Code:
PS C:\WINDOWS\system32> (Get-CimInstance -ClassName MS_SystemInformation -NameSpace root\WMI).SystemSKU.Trim()
823Y4AA#ABA
IsUEFI
Description: Lists all mac addresses of the device, can be several
PowerShell: Get-SecureBootUEFI
Returned Values: True | False
PowerShell Code:
$LocalInfo = @{}
try {
Get-SecureBootUEFI -Name SetupMode | Out-Null
$LocalInfo['IsUEFI'] = "True"
}
catch {
$LocalInfo['IsUEFI'] = "False"
}
Name Value
---- -----
IsUEFI True
SetupMode
Description: Lists all mac addresses of the device, can be several
PowerShell: Get-SecureBootUEFI
Returned Values: BIOS | UEFI
PowerShell Code:
$LocalInfo = @{}
try {
Get-SecureBootUEFI -Name SetupMode | Out-Null
$LocalInfo['SetupMode'] = "UEFI"
}
catch {
$LocalInfo['SetupMode'] = "BIOS"
}
PS C:\WINDOWS\system32> $LocalInfo
Name Value
---- -----
SetupMode UEFI
IsOnBattery
Description: is created if the device has a battery and is currently on battery. If it does not have a battery, or is currently on AC, it will skip creating the variable.
WMI: Win32_Battery
Returned Values: TRUE
PowerShell Code:
$LocalInfo = @{}
$bFoundAC = $false
$bOnBattery = $false
$bFoundBattery = $false
foreach ($Battery in (Get-CimInstance -ClassName Win32_Battery)) {
$bFoundBattery = $true
if ($Battery.BatteryStatus -eq "2") {
$bFoundAC = $true
}
}
If ($bFoundBattery -and !$bFoundAC) {
$LocalInfo['IsOnBattery'] = $true
}
OSSku
Description: Determines the Edition or SKU of Windows on the computer, info from: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getproductinfo
WMI: win32_operatingsystem
Returned Values: Number, 0-85 then Translated to Edition
PowerShell Code:
$LocalInfo = @{}
$sku = (Get-CimInstance -ClassName win32_operatingsystem).OperatingSystemSKU
switch ($sku)
{
0 {$LocalInfo['OSSku']="Undefined";break}
1 {$LocalInfo['OSSku']="Ultimate Edition";break}
2 {$LocalInfo['OSSku']="Home Basic Edition";break}
3 {$LocalInfo['OSSku']="Home Basic Premium Edition";break}
4 {$LocalInfo['OSSku']="Enterprise Edition";break}
5 {$LocalInfo['OSSku']="Home Basic N Edition";break}
6 {$LocalInfo['OSSku']="Business Edition";break}
7 {$LocalInfo['OSSku']="Standard Server Edition";break}
8 {$LocalInfo['OSSku']="Datacenter Server Edition";break}
9 {$LocalInfo['OSSku']="Small Business Server Edition";break}
10 {$LocalInfo['OSSku']="Enterprise Server Edition";break}
11 {$LocalInfo['OSSku']="Web Server";break}
12 {$LocalInfo['OSSku']="Datacenter Server Core Edition";break}
13 {$LocalInfo['OSSku']="Standard Server Core Edition";break}
14 {$LocalInfo['OSSku']="Enterprise Server Core Edition";break}
15 {$LocalInfo['OSSku']="Storage Server Standard";break}
16 {$LocalInfo['OSSku']="Storage Server Workgroup";break}
17 {$LocalInfo['OSSku']="Storage Server Enterprise";break}
18 {$LocalInfo['OSSku']="Windows Essential Server Solutions";break}
19 {$LocalInfo['OSSku']="Small Business Server Premium";break}
20 {$LocalInfo['OSSku']="Storage Express Server Edition";break}
21 {$LocalInfo['OSSku']="Server Foundation";break}
22 {$LocalInfo['OSSku']="Storage Workgroup Server Edition";break}
23 {$LocalInfo['OSSku']="Windows Essential Server Solutions";break}
24 {$LocalInfo['OSSku']="Server For Small Business Edition";break}
25 {$LocalInfo['OSSku']="Small Business Server Premium Edition";break}
30 {$LocalInfo['OSSku']="Pro Edition";break}
40 {$LocalInfo['OSSku']="Server Hyper Core V";break}
48 {$LocalInfo['OSSku']="Enterprise Edition";break}
50 {$LocalInfo['OSSku']="Datacenter Server Edition";break}
54 {$LocalInfo['OSSku']="Enterpise N Edition";break}
62 {$LocalInfo['OSSku']="Home N Edition";break}
65 {$LocalInfo['OSSku']="Home Edition";break}
68 {$LocalInfo['OSSku']="Mobile Edition";break}
79 {$LocalInfo['OSSku']="Education Edition";break}
81 {$LocalInfo['OSSku']="Enterprise 2015 LTSB";break}
82 {$LocalInfo['OSSku']="Enterprise 2015 N LTSB";break}
85 {$LocalInfo['OSSku']="Mobile Enterprise";break}
default {$LocalInfo['OSSku']="Not Supported";break}
}
PS C:\WINDOWS\system32> $LocalInfo
Name Value
---- -----
OSSku Enterprise Edition
Last updated