@@ -81,21 +81,20 @@ function Private:New-ADTEnvironmentTable
8181 $variables.Add (' RunningDeployrTaskSequence' , ! [System.String ]::IsNullOrWhiteSpace([PSADT.Utilities.EnvironmentUtilities ]::GetEnvironmentVariable(' DEPLOYR_PROCESS' )))
8282
8383 # # Variables: Domain Membership
84- $w32cs = Get-CimInstance - ClassName Win32_ComputerSystem - Verbose:$false
85- $w32csd = $w32cs.Domain | & { process { if ($_ ) { return $_ } } } | Select-Object - First 1
86- $variables.Add (' IsMachinePartOfDomain' , $w32cs.PartOfDomain )
84+ $domainInfo = [PSADT.DeviceManagement.DeviceUtilities ]::GetDomainStatus()
85+ $variables.Add (' IsMachinePartOfDomain' , $domainInfo.JoinStatus.Equals ([PSADT.LibraryInterfaces.NETSETUP _JOIN _STATUS ]::NetSetupDomainName))
8786 $variables.Add (' envMachineWorkgroup' , $null )
8887 $variables.Add (' envMachineADDomain' , $null )
8988 $variables.Add (' envLogonServer' , $null )
9089 $variables.Add (' MachineDomainController' , $null )
9190 $variables.Add (' envMachineDNSDomain' , ([System.Net.NetworkInformation.IPGlobalProperties ]::GetIPGlobalProperties().DomainName | & { process { if ($_ ) { return $_.ToLowerInvariant () } } } | Select-Object - First 1 ))
9291 $variables.Add (' envUserDNSDomain' , ([PSADT.Utilities.EnvironmentUtilities ]::GetEnvironmentVariable(' USERDNSDOMAIN' ) | & { process { if ($_ ) { return $_.ToLowerInvariant () } } } | Select-Object - First 1 ))
9392 $variables.Add (' envUserDomain' , $ (if ([System.Environment ]::UserDomainName) { [System.Environment ]::UserDomainName.ToUpperInvariant() }))
94- $variables.Add (' envComputerName' , $w32cs .DNSHostName .ToUpperInvariant ())
93+ $variables.Add (' envComputerName' , [ System.Net.Dns ]::GetHostName() .ToUpperInvariant())
9594 $variables.Add (' envComputerNameFQDN' , $variables.envComputerName )
9695 if ($variables.IsMachinePartOfDomain )
9796 {
98- $variables.envMachineADDomain = $w32csd .ToLowerInvariant ()
97+ $variables.envMachineADDomain = $domainInfo .DomainOrWorkgroupName .ToLowerInvariant ()
9998 $variables.envComputerNameFQDN = try
10099 {
101100 [System.Net.Dns ]::GetHostEntry(' localhost' ).HostName
@@ -132,7 +131,7 @@ function Private:New-ADTEnvironmentTable
132131 }
133132 else
134133 {
135- $variables.envMachineWorkgroup = $w32csd .ToUpperInvariant ()
134+ $variables.envMachineWorkgroup = $domainInfo .DomainOrWorkgroupName .ToUpperInvariant ()
136135 }
137136
138137 # Get the OS Architecture.
@@ -221,11 +220,12 @@ function Private:New-ADTEnvironmentTable
221220 }))
222221
223222 # # Variables: Hardware
224- $w32b = Get-CimInstance - ClassName Win32_BIOS - Verbose:$false
225- $w32bVersion = $w32b | Select-Object - ExpandProperty Version - ErrorAction Ignore
226- $w32bSerialNumber = $w32b | Select-Object - ExpandProperty SerialNumber - ErrorAction Ignore
227- $variables.Add (' envSystemRAM' , [System.Math ]::Round($w32cs.TotalPhysicalMemory / 1 GB ))
228- $variables.Add (' envHardwareType' , $ (if (($w32bVersion -match ' VRTUAL' ) -or (($w32cs.Manufacturer -like ' *Microsoft*' ) -and ($w32cs.Model -notlike ' *Surface*' )))
223+ $w32bVersion = [PSADT.DeviceManagement.HardwareInfo ]::SystemInformation.Version
224+ $w32bSerialNumber = [PSADT.DeviceManagement.HardwareInfo ]::SystemInformation.SerialNumber
225+ $w32bManufacturer = [PSADT.DeviceManagement.HardwareInfo ]::SystemInformation.Manufacturer
226+ $w32bProductName = [PSADT.DeviceManagement.HardwareInfo ]::SystemInformation.ProductName
227+ $variables.Add (' envSystemRAM' , [System.Math ]::Round([PSADT.DeviceManagement.DeviceUtilities ]::GetTotalSystemMemory() / 1 GB ))
228+ $variables.Add (' envHardwareType' , $ (if (($w32bVersion -match ' VRTUAL' ) -or (($w32bManufacturer -like ' *Microsoft*' ) -and ($w32bProductName -notlike ' *Surface*' )))
229229 {
230230 ' Virtual:Hyper-V'
231231 }
@@ -237,15 +237,15 @@ function Private:New-ADTEnvironmentTable
237237 {
238238 ' Virtual:Xen'
239239 }
240- elseif (($w32bSerialNumber -like ' *VMware*' ) -or ($w32cs .Manufacturer -like ' *VMWare*' ))
240+ elseif (($w32bSerialNumber -like ' *VMware*' ) -or ($w32bManufacturer -like ' *VMWare*' ))
241241 {
242242 ' Virtual:VMware'
243243 }
244- elseif (($w32bSerialNumber -like ' *Parallels*' ) -or ($w32cs .Manufacturer -like ' *Parallels*' ))
244+ elseif (($w32bSerialNumber -like ' *Parallels*' ) -or ($w32bManufacturer -like ' *Parallels*' ))
245245 {
246246 ' Virtual:Parallels'
247247 }
248- elseif ($w32cs .Model -like ' *Virtual*' )
248+ elseif ($w32bProductName -like ' *Virtual*' )
249249 {
250250 ' Virtual'
251251 }
0 commit comments