@@ -80,21 +80,20 @@ function Private:New-ADTEnvironmentTable
8080 $variables.Add (' RunningTaskSequence' , !! [System.Type ]::GetTypeFromProgID(' Microsoft.SMS.TSEnvironment' ))
8181
8282 # # Variables: Domain Membership
83- $w32cs = Get-CimInstance - ClassName Win32_ComputerSystem - Verbose:$false
84- $w32csd = $w32cs.Domain | & { process { if ($_ ) { return $_ } } } | Select-Object - First 1
85- $variables.Add (' IsMachinePartOfDomain' , $w32cs.PartOfDomain )
83+ $domainInfo = [PSADT.DeviceManagement.DeviceUtilities ]::GetDomainStatus()
84+ $variables.Add (' IsMachinePartOfDomain' , $domainInfo.JoinStatus.Equals ([PSADT.LibraryInterfaces.NETSETUP _JOIN _STATUS ]::NetSetupDomainName))
8685 $variables.Add (' envMachineWorkgroup' , $null )
8786 $variables.Add (' envMachineADDomain' , $null )
8887 $variables.Add (' envLogonServer' , $null )
8988 $variables.Add (' MachineDomainController' , $null )
9089 $variables.Add (' envMachineDNSDomain' , ([System.Net.NetworkInformation.IPGlobalProperties ]::GetIPGlobalProperties().DomainName | & { process { if ($_ ) { return $_.ToLowerInvariant () } } } | Select-Object - First 1 ))
9190 $variables.Add (' envUserDNSDomain' , ([System.Environment ]::GetEnvironmentVariable(' USERDNSDOMAIN' ) | & { process { if ($_ ) { return $_.ToLowerInvariant () } } } | Select-Object - First 1 ))
9291 $variables.Add (' envUserDomain' , $ (if ([System.Environment ]::UserDomainName) { [System.Environment ]::UserDomainName.ToUpperInvariant() }))
93- $variables.Add (' envComputerName' , $w32cs .DNSHostName .ToUpperInvariant ())
92+ $variables.Add (' envComputerName' , [ System.Net.Dns ]::GetHostName() .ToUpperInvariant())
9493 $variables.Add (' envComputerNameFQDN' , $variables.envComputerName )
9594 if ($variables.IsMachinePartOfDomain )
9695 {
97- $variables.envMachineADDomain = $w32csd .ToLowerInvariant ()
96+ $variables.envMachineADDomain = $domainInfo .DomainOrWorkgroupName .ToLowerInvariant ()
9897 $variables.envComputerNameFQDN = try
9998 {
10099 [System.Net.Dns ]::GetHostEntry(' localhost' ).HostName
@@ -131,7 +130,7 @@ function Private:New-ADTEnvironmentTable
131130 }
132131 else
133132 {
134- $variables.envMachineWorkgroup = $w32csd .ToUpperInvariant ()
133+ $variables.envMachineWorkgroup = $domainInfo .DomainOrWorkgroupName .ToUpperInvariant ()
135134 }
136135
137136 # Get the OS Architecture.
@@ -216,11 +215,12 @@ function Private:New-ADTEnvironmentTable
216215 }))
217216
218217 # # Variables: Hardware
219- $w32b = Get-CimInstance - ClassName Win32_BIOS - Verbose:$false
220- $w32bVersion = $w32b | Select-Object - ExpandProperty Version - ErrorAction Ignore
221- $w32bSerialNumber = $w32b | Select-Object - ExpandProperty SerialNumber - ErrorAction Ignore
222- $variables.Add (' envSystemRAM' , [System.Math ]::Round($w32cs.TotalPhysicalMemory / 1 GB ))
223- $variables.Add (' envHardwareType' , $ (if (($w32bVersion -match ' VRTUAL' ) -or (($w32cs.Manufacturer -like ' *Microsoft*' ) -and ($w32cs.Model -notlike ' *Surface*' )))
218+ $w32bVersion = [PSADT.DeviceManagement.HardwareInfo ]::SystemInformation.Version
219+ $w32bSerialNumber = [PSADT.DeviceManagement.HardwareInfo ]::SystemInformation.SerialNumber
220+ $w32bManufacturer = [PSADT.DeviceManagement.HardwareInfo ]::SystemInformation.Manufacturer
221+ $w32bProductName = [PSADT.DeviceManagement.HardwareInfo ]::SystemInformation.ProductName
222+ $variables.Add (' envSystemRAM' , [System.Math ]::Round([PSADT.DeviceManagement.DeviceUtilities ]::GetTotalSystemMemory() / 1 GB ))
223+ $variables.Add (' envHardwareType' , $ (if (($w32bVersion -match ' VRTUAL' ) -or (($w32bManufacturer -like ' *Microsoft*' ) -and ($w32bProductName -notlike ' *Surface*' )))
224224 {
225225 ' Virtual:Hyper-V'
226226 }
@@ -232,15 +232,15 @@ function Private:New-ADTEnvironmentTable
232232 {
233233 ' Virtual:Xen'
234234 }
235- elseif (($w32bSerialNumber -like ' *VMware*' ) -or ($w32cs .Manufacturer -like ' *VMWare*' ))
235+ elseif (($w32bSerialNumber -like ' *VMware*' ) -or ($w32bManufacturer -like ' *VMWare*' ))
236236 {
237237 ' Virtual:VMware'
238238 }
239- elseif (($w32bSerialNumber -like ' *Parallels*' ) -or ($w32cs .Manufacturer -like ' *Parallels*' ))
239+ elseif (($w32bSerialNumber -like ' *Parallels*' ) -or ($w32bManufacturer -like ' *Parallels*' ))
240240 {
241241 ' Virtual:Parallels'
242242 }
243- elseif ($w32cs .Model -like ' *Virtual*' )
243+ elseif ($w32bProductName -like ' *Virtual*' )
244244 {
245245 ' Virtual'
246246 }
0 commit comments