DeviceInventory.psm1
function Get-AzureADInfo { # Azure registry locations $AzureADTenantInfoRegistryKeyPath = "HKLM:\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\TenantInfo" $AzureADJoinInfoRegistryKeyPath = "HKLM:\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\JoinInfo" # get AAD tenant ID $AzureADTenantID = $null if (Test-Path $AzureADTenantInfoRegistryKeyPath) { $AzureADTenantID = Get-ChildItem -Path $AzureADTenantInfoRegistryKeyPath | Select-Object -ExpandProperty "PSChildName" } # get AAD device ID if (Test-Path $AzureADJoinInfoRegistryKeyPath) { $AzureADJoinInfoThumbprint = Get-ChildItem -Path $AzureADJoinInfoRegistryKeyPath | Select-Object -ExpandProperty "PSChildName" } if ($null -ne $AzureADJoinInfoThumbprint) { $AzureADJoinCertificate = Get-ChildItem -Path "Cert:\LocalMachine\My" -Recurse | Where-Object { $PSItem.Thumbprint -eq $AzureADJoinInfoThumbprint } if ($null -ne $AzureADJoinCertificate) { $AzureADJoinDate = ($AzureADJoinCertificate | Select-Object -ExpandProperty "NotBefore") $AzureADDeviceID = ($AzureADJoinCertificate | Select-Object -ExpandProperty "Subject") -replace "CN=", "" } } # get AAD managed device name and ID if (@(Get-ChildItem HKLM:SOFTWARE\Microsoft\Enrollments\ -Recurse | Where-Object { $_.PSChildName -eq 'MS DM Server' })) { $MSDMServerInfo = Get-ChildItem HKLM:SOFTWARE\Microsoft\Enrollments\ -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.PSChildName -eq 'MS DM Server' } $ManagedDeviceInfo = Get-ItemProperty -LiteralPath "Registry::$($MSDMServerInfo)" -ErrorAction SilentlyContinue } $ManagedDeviceName = $ManagedDeviceInfo.EntDeviceName $ManagedDeviceID = $ManagedDeviceInfo.EntDMID $temparray = New-Object -TypeName PSObject $temparray | Add-Member -MemberType NoteProperty -Name "AzureADTenantID" -Value $AzureADTenantID -Force $temparray | Add-Member -MemberType NoteProperty -Name "AzureADJoinDate" -Value $AzureADJoinDate -Force $temparray | Add-Member -MemberType NoteProperty -Name "ManagedDeviceName" -Value $ManagedDeviceName -Force $temparray | Add-Member -MemberType NoteProperty -Name "ManagedDeviceID" -Value $ManagedDeviceID -Force return $temparray } function Get-InstalledApplications() { # if usersid is not supplied, only machine wide apps are considered param ( [string]$UserSid ) # get apps from registry (user and machine) New-PSDrive -PSProvider Registry -Name "HKU" -Root HKEY_USERS | Out-Null $regpath = @("HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*") $regpath += "HKU:\$UserSid\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" if (-not ([IntPtr]::Size -eq 4)) { $regpath += "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" $regpath += "HKU:\$UserSid\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" } $propertyNames = 'DisplayName', 'DisplayVersion', 'Publisher', 'UninstallString' $Apps = Get-ItemProperty $regpath -Name $propertyNames -ErrorAction SilentlyContinue | . { process { if ($_.DisplayName) { $_ } } } | Select-Object DisplayName, DisplayVersion, Publisher, UninstallString, PSPath | Sort-Object DisplayName Remove-PSDrive -Name "HKU" | Out-Null Return $Apps } function Get-ComputerSystemInfo { # Get Computer system information (hardware, OS, bios) $ComputerOSInfo = Get-CimInstance -ClassName Win32_OperatingSystem $ComputerInfo = Get-CimInstance -ClassName Win32_ComputerSystem $ComputerBiosInfo = Get-CimInstance -ClassName Win32_Bios # get hardware properties $ComputerManufacturer = $ComputerInfo.Manufacturer $ComputerModel = $ComputerInfo.Model $ComputerSystemSKU = $ComputerInfo.SystemSKUNumber $ComputerSerialNr = $ComputerBiosInfo.SerialNumber $ComputerBiosUUID = Get-CimInstance Win32_ComputerSystemProduct | Select-Object -ExpandProperty UUID $ComputerFirmwareType = $env:firmware_type $PCSystemType = $ComputerInfo.PCSystemType switch ($PCSystemType){ 0 {$ComputerPCSystemType = "Unspecified"} 1 {$ComputerPCSystemType = "Desktop"} 2 {$ComputerPCSystemType = "Laptop"} 3 {$ComputerPCSystemType = "Workstation"} 4 {$ComputerPCSystemType = "EnterpriseServer"} 5 {$ComputerPCSystemType = "SOHOServer"} 6 {$ComputerPCSystemType = "AppliancePC"} 7 {$ComputerPCSystemType = "PerformanceServer"} 8 {$ComputerPCSystemType = "Maximum"} default {$ComputerPCSystemType = "Unspecified"} } $PCSystemTypeEx = $ComputerInfo.PCSystemTypeEx switch ($PCSystemTypeEx){ 0 {$ComputerPCSystemTypeEx = "Unspecified"} 1 {$ComputerPCSystemTypeEx = "Desktop"} 2 {$ComputerPCSystemTypeEx = "Laptop"} 3 {$ComputerPCSystemTypeEx = "Workstation"} 4 {$ComputerPCSystemTypeEx = "EnterpriseServer"} 5 {$ComputerPCSystemTypeEx = "SOHOServer"} 6 {$ComputerPCSystemTypeEx = "AppliancePC"} 7 {$ComputerPCSystemTypeEx = "PerformanceServer"} 8 {$ComputerPCSystemTypeEx = "Slate"} 9 {$ComputerPCSystemTypeEx = "Maximum"} default {$ComputerPCSystemTypeEx = "Unspecified"} } # get memory and cpu info $ComputerPhysicalMemoryGB = [Math]::Round(($ComputerInfo.TotalPhysicalMemory / 1GB)) $ComputerCPU = Get-CimInstance win32_processor $ComputerProcessorManufacturer = $ComputerCPU.Manufacturer | Get-Unique $ComputerProcessorName = $ComputerCPU.Name | Get-Unique $ComputerNumberOfCores = $ComputerCPU.NumberOfCores | Get-Unique $ComputerNumberOfLogicalProcessors = $ComputerCPU.NumberOfLogicalProcessors | Get-Unique # get os properties $ComputerInstallDate = $ComputerOSInfo.InstallDate $ComputerLastBoot = $ComputerOSInfo.LastBootUpTime $ComputerUptime = [int](New-TimeSpan -Start $ComputerLastBoot).Days $DisplayVersion = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name DisplayVersion -ErrorAction SilentlyContinue).DisplayVersion if ([string]::IsNullOrEmpty($DisplayVersion)) { $ComputerWindowsVersion = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ReleaseId).ReleaseId } else { $ComputerWindowsVersion = $DisplayVersion } $ComputerOSName = $ComputerOSInfo.Caption $ComputerOSBuild = $ComputerOSInfo.BuildNumber $ComputerOSRevision = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name UBR).UBR $temparray = New-Object -TypeName PSObject $temparray | Add-Member -MemberType NoteProperty -Name "ComputerManufacturer" -Value $ComputerManufacturer -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerModel" -Value $ComputerModel -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerSystemSKU" -Value $ComputerSystemSKU -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerSerialNr" -Value $ComputerSerialNr -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerBiosUUID" -Value $ComputerBiosUUID -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerFirmwareType" -Value $ComputerFirmwareType -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerPCSystemType" -Value $ComputerPCSystemType -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerPCSystemTypeEx" -Value $ComputerPCSystemTypeEx -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerPhysicalMemoryGB" -Value $ComputerPhysicalMemoryGB -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerProcessorManufacturer" -Value $ComputerProcessorManufacturer -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerProcessorName" -Value $ComputerProcessorName -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerNumberOfCores" -Value $ComputerNumberOfCores -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerNumberOfLogicalProcessors" -Value $ComputerNumberOfLogicalProcessors -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerInstallDate" -Value $ComputerInstallDate -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerUptime" -Value $ComputerUptime -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerWindowsVersion" -Value $ComputerWindowsVersion -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerOSName" -Value $ComputerOSName -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerOSBuild" -Value $ComputerOSBuild -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerOSRevision" -Value $ComputerOSRevision -Force return $temparray } function Get-BiosInfo { # get bios version and date $ComputerBiosInfo = Get-CimInstance -ClassName Win32_Bios $ComputerBiosVersion = $ComputerBiosInfo.SMBIOSBIOSVersion $ComputerBiosDate = $ComputerBiosInfo.ReleaseDate $ComputerManufacturer = (Get-CimInstance -ClassName Win32_ComputerSystem).Manufacturer if ($ComputerManufacturer -match "Hewlett-Packard") { $ComputerManufacturer = "HP" } # transform bios version to uniform format switch -Wildcard ($ComputerManufacturer) { "*HP*" { $CurrentBIOSProperties = (Get-WmiObject -Class Win32_BIOS | Select-Object -Property *) # Detect new versus old BIOS formats switch -wildcard ($($CurrentBIOSProperties.SMBIOSBIOSVersion)) { "*ver*" { if ($CurrentBIOSProperties.SMBIOSBIOSVersion -match '.F.\d+$') { $ComputerBiosVersion = ($CurrentBIOSProperties.SMBIOSBIOSVersion -split "Ver.")[1].Trim() } else { $ComputerBiosVersion = [System.Version]::Parse(($CurrentBIOSProperties.SMBIOSBIOSVersion).TrimStart($CurrentBIOSProperties.SMBIOSBIOSVersion.Split(".")[0]).TrimStart(".").Trim().Split(" ")[0]) } } default { $ComputerBiosVersion = "$($CurrentBIOSProperties.SystemBiosMajorVersion).$($CurrentBIOSProperties.SystemBiosMinorVersion)" } } } "*Dell*" { $ComputerBiosVersion = (Get-WmiObject -Class Win32_BIOS | Select-Object -ExpandProperty SMBIOSBIOSVersion).Trim() } "*Lenovo*" { $CurrentBIOSProperties = (Get-WmiObject -Class Win32_BIOS | Select-Object -Property *) $ComputerBiosVersion = "$($CurrentBIOSProperties.SystemBiosMajorVersion).$($CurrentBIOSProperties.SystemBiosMinorVersion)" } } $temparray = New-Object -TypeName PSObject $temparray | Add-Member -MemberType NoteProperty -Name "ComputerBiosVersion" -Value $ComputerBiosVersion -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerBiosDate" -Value $ComputerBiosDate -Force return $temparray } function Get-TpmAndBitlockerInfo { # get tpm info $TpmInfo = Get-WmiObject -Namespace "root\cimv2\security\microsofttpm" -Class win32_tpm $TpmSpecVersion = $TpmInfo.SpecVersion $TpmPhysicalPresenceVersionInfo = $TpmInfo.PhysicalPresenceVersionInfo try { $TPMValues = Get-Tpm -ErrorAction SilentlyContinue | Select-Object -Property * } catch { $TPMValues = $null } try { $BitLockerInfo = Get-BitLockerVolume -MountPoint $env:SystemDrive | Select-Object -Property * } catch { $BitLockerInfo = $null } $ComputerTPMReady = $TPMValues.TPMReady $ComputerTPMPresent = $TPMValues.TPMPresent $ComputerTPMEnabled = $TPMValues.TPMEnabled $ComputerTPMActivated = $TPMValues.TPMActivated $ComputerBitlockerCipher = $BitLockerInfo.EncryptionMethod $ComputerBitlockerStatus = $BitLockerInfo.VolumeStatus $ComputerBitlockerProtection = $BitLockerInfo.ProtectionStatus $ComputerBitlockerMountPoint = $BitLockerInfo.MountPoint $ComputerBitlockerEncryptionPercentage = $BitLockerInfo.EncryptionPercentage $ComputerBitlockerKeyProtector = $BitLockerInfo.KeyProtector $temparray = New-Object -TypeName PSObject $temparray | Add-Member -MemberType NoteProperty -Name "TpmSpecVersion" -Value $TpmSpecVersion -Force $temparray | Add-Member -MemberType NoteProperty -Name "TpmPhysicalPresenceVersionInfo" -Value $TpmPhysicalPresenceVersionInfo -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerTPMReady" -Value $ComputerTPMReady -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerTPMPresent" -Value $ComputerTPMPresent -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerTPMEnabled" -Value $ComputerTPMEnabled -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerTPMActivated" -Value $ComputerTPMActivated -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerBitlockerCipher" -Value $ComputerBitlockerCipher -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerBitlockerStatus" -Value $ComputerBitlockerStatus -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerBitlockerProtection" -Value $ComputerBitlockerProtection -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerBitlockerMountPoint" -Value $ComputerBitlockerMountPoint -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerBitlockerEncryptionPercentage" -Value $ComputerBitlockerEncryptionPercentage -Force $temparray | Add-Member -MemberType NoteProperty -Name "ComputerBitlockerKeyProtector" -Value $ComputerBitlockerKeyProtector -Force return $temparray } function Get-NetworkInfo { # get relevant nic adapter(s) info $NetWorkArray = @() # $CurrentNetAdapters = Get-NetAdapter | Where-Object {$_.Name -notmatch "vEthernet" -and $_.PhysicalMediaType -notmatch "Unspecified"} # $CurrentNetAdapters = Get-NetAdapter | Where-Object { $_.Status -eq 'Up' } $CurrentNetAdapters = Get-NetAdapter foreach ($CurrentNetAdapter in $CurrentNetAdapters) { $IPConfiguration = Get-NetIPConfiguration -InterfaceIndex $CurrentNetAdapter[0].ifIndex $ComputerNetInterfaceDescription = $CurrentNetAdapter.InterfaceDescription $ComputerNetProfileName = $IPConfiguration.NetProfile.Name $ComputerNetIPv4Adress = $IPConfiguration.IPv4Address.IPAddress $ComputerNetInterfaceAlias = $CurrentNetAdapter.InterfaceAlias $ComputerNetIPv4DefaultGateway = $IPConfiguration.IPv4DefaultGateway.NextHop $ComputerNetMacAddress = $CurrentNetAdapter.MacAddress $ComputerNetLinkSpeed = $CurrentNetAdapter.LinkSpeed $ComputerNetInterfaceDriverVersion = $CurrentNetAdapter.DriverVersion $ComputerNetInterfaceDriverDate = $CurrentNetAdapter.DriverDate $ComputerNetInterfaceDriverDescription = $CurrentNetAdapter.DriverDescription $temparray = New-Object -TypeName PSObject $temparray | Add-Member -MemberType NoteProperty -Name "NetInterfaceDescription" -Value "$ComputerNetInterfaceDescription" -Force $temparray | Add-Member -MemberType NoteProperty -Name "NetProfileName" -Value "$ComputerNetProfileName" -Force $temparray | Add-Member -MemberType NoteProperty -Name "NetIPv4Adress" -Value "$ComputerNetIPv4Adress" -Force $temparray | Add-Member -MemberType NoteProperty -Name "NetInterfaceAlias" -Value "$ComputerNetInterfaceAlias" -Force $temparray | Add-Member -MemberType NoteProperty -Name "NetIPv4DefaultGateway" -Value "$ComputerNetIPv4DefaultGateway" -Force $temparray | Add-Member -MemberType NoteProperty -Name "MacAddress" -Value "$ComputerNetMacAddress" -Force $temparray | Add-Member -MemberType NoteProperty -Name "LinkSpeed" -Value "$ComputerNetLinkSpeed" -Force $temparray | Add-Member -MemberType NoteProperty -Name "DriverVersion" -Value $ComputerNetInterfaceDriverVersion $temparray | Add-Member -MemberType NoteProperty -Name "DriverDate" -Value $ComputerNetInterfaceDriverDate $temparray | Add-Member -MemberType NoteProperty -Name "DriverDescription" -Value $ComputerNetInterfaceDriverDescription $NetWorkArray += $temparray } [System.Collections.ArrayList]$NetWorkArrayList = $NetWorkArray return $NetWorkArrayList } function Get-LocationInfo { #Get Device Location $ComputerPublicIP = (Invoke-WebRequest -UseBasicParsing -uri "http://ifconfig.me/ip").Content $Computerlocation = Invoke-RestMethod -Method Get -Uri "http://ip-api.com/json/$ComputerPublicIP" $ComputerCountry = $Computerlocation.country $ComputerCity = $Computerlocation.city $ComputerISP = $Computerlocation.isp $temparray = New-Object -TypeName PSObject $temparray | Add-Member -MemberType NoteProperty -Name "ComputerPublicIP" -Value $ComputerPublicIP $temparray | Add-Member -MemberType NoteProperty -Name "ComputerCountry" -Value $ComputerCountry $temparray | Add-Member -MemberType NoteProperty -Name "ComputerCity" -Value $ComputerCity $temparray | Add-Member -MemberType NoteProperty -Name "ComputerISP" -Value $ComputerISP return $temparray } function Get-BatteryInfo { # Get Battery info and health $BatteryArray = @() $Batteries = Get-WmiObject -Class "BatteryStaticData" -Namespace "ROOT\WMI" foreach ($Battery in $Batteries) { $BatteryFullChargedCapacity = Get-WmiObject -Class "BatteryFullChargedCapacity" -Namespace "ROOT\WMI" | Where-Object {$_.InstanceName -eq $Battery.InstanceName} $temparray = New-Object -TypeName PSObject $temparray | Add-Member -MemberType NoteProperty -Name "Name" -Value $Battery.DeviceName -Force $temparray | Add-Member -MemberType NoteProperty -Name "FullChargedCapacity" -Value $BatteryFullChargedCapacity.FullChargedCapacity $temparray | Add-Member -MemberType NoteProperty -Name "DesignedCapacity" -Value $Battery.DesignedCapacity $BatteryArray += $temparray } [System.Collections.ArrayList]$BatteryArrayList = $BatteryArray return $BatteryArrayList } function Get-DiskInfo { # Get disk(s) health and general info $DiskArray = @() $Disks = Get-PhysicalDisk | Where-Object { $_.BusType -match "NVMe|SATA|SAS|ATAPI|RAID" } foreach ($Disk in ($Disks | Sort-Object DeviceID)) { $DiskHealth = Get-PhysicalDisk -UniqueId $($Disk.UniqueId) | Get-StorageReliabilityCounter | Select-Object -Property Wear, ReadErrorsTotal, ReadErrorsUncorrected, WriteErrorsTotal, WriteErrorsUncorrected, Temperature, TemperatureMax $DriveDetails = Get-PhysicalDisk -UniqueId $($Disk.UniqueId) | Select-Object MediaType, HealthStatus $DriveMediaType = $DriveDetails.MediaType $DriveHealthState = $DriveDetails.HealthStatus $DiskTempDelta = [int]$($DiskHealth.Temperature) - [int]$($DiskHealth.TemperatureMax) $temparray = new-object -TypeName PSObject $temparray | Add-Member -MemberType NoteProperty -Name "Disk Number" -Value $Disk.DeviceID $temparray | Add-Member -MemberType NoteProperty -Name "FriendlyName" -Value $($Disk.FriendlyName) $temparray | Add-Member -MemberType NoteProperty -Name "SizeGB" -Value $([int]($Disk.Size/1GB)) $temparray | Add-Member -MemberType NoteProperty -Name "HealthStatus" -Value $DriveHealthState $temparray | Add-Member -MemberType NoteProperty -Name "MediaType" -Value $DriveMediaType $temparray | Add-Member -MemberType NoteProperty -Name "Disk Wear" -Value $([int]($DiskHealth.Wear)) $temparray | Add-Member -MemberType NoteProperty -Name "Disk $($Disk.DeviceID) Read Errors" -Value $([int]($DiskHealth.ReadErrorsTotal)) $temparray | Add-Member -MemberType NoteProperty -Name "Disk $($Disk.DeviceID) Temperature Delta" -Value $DiskTempDelta $temparray | Add-Member -MemberType NoteProperty -Name "Disk $($Disk.DeviceID) ReadErrorsUncorrected" -Value $($Disk.ReadErrorsUncorrected) $temparray | Add-Member -MemberType NoteProperty -Name "Disk $($Disk.DeviceID) ReadErrorsTotal" -Value $($Disk.ReadErrorsTotal) $temparray | Add-Member -MemberType NoteProperty -Name "Disk $($Disk.DeviceID) WriteErrorsUncorrected" -Value $($Disk.WriteErrorsUncorrected) $temparray | Add-Member -MemberType NoteProperty -Name "Disk $($Disk.DeviceID) WriteErrorsTotal" -Value $($Disk.WriteErrorsTotal) $DiskArray += $temparray } [System.Collections.ArrayList]$DiskHealthArrayList = $DiskArray return $DiskHealthArrayList } function Get-BiosSettings { # get bios settings $ComputerManufacturer = (Get-CimInstance -ClassName Win32_ComputerSystem).Manufacturer if ($ComputerManufacturer -match "Hewlett-Packard") { $ComputerManufacturer = "HP" } if ($ComputerManufacturer -match 'HP') { # Get HP BIOS settings $BiosSettings = Get-WmiObject -Namespace "root\hp\InstrumentedBIOS" -ClassName "HP_BIOSEnumeration" -ErrorAction SilentlyContinue $BiosArray = @() foreach ($Setting in $BiosSettings) { $temparray = new-object -TypeName PSObject $temparray | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value "$ComputerName" -Force $temparray | Add-Member -MemberType NoteProperty -Name "ManagedDeviceName" -Value "$ManagedDeviceName" -Force $temparray | Add-Member -MemberType NoteProperty -Name "ManagedDeviceID" -Value "$ManagedDeviceID" -Force $temparray | Add-Member -MemberType NoteProperty -Name "AADDeviceID" -Value "$AADDeviceID" -Force $temparray | Add-Member -MemberType NoteProperty -Name "Name" -Value "$($Setting.Name)" -Force $temparray | Add-Member -MemberType NoteProperty -Name "CurrentValue" -Value "$($Setting.CurrentValue)" -Force $temparray | Add-Member -MemberType NoteProperty -Name "Value" -Value "$($Setting.Value)" -Force $temparray | Add-Member -MemberType NoteProperty -Name "IsReadOnly" -Value "$($Setting.IsReadOnly)" -Force $temparray | Add-Member -MemberType NoteProperty -Name "DisplayInUI" -Value "$($Setting.DisplayInUI)" -Force $temparray | Add-Member -MemberType NoteProperty -Name "Path" -Value "$($Setting.Path)" -Force $BiosArray += $temparray } } elseif ($ComputerManufacturer -match 'Dell') { # Get Dell BIOS settings $BiosSettings = Get-CimInstance -Namespace "root\dcim\sysman\biosattributes" -ClassName "IntegerAttribute" -ErrorAction SilentlyContinue $BiosArray = @() foreach ($Setting in $BiosSettings) { $temparray = new-object -TypeName PSObject $temparray | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value "$ComputerName" -Force $temparray | Add-Member -MemberType NoteProperty -Name "ManagedDeviceName" -Value "$ManagedDeviceName" -Force $temparray | Add-Member -MemberType NoteProperty -Name "ManagedDeviceID" -Value "$ManagedDeviceID" -Force $temparray | Add-Member -MemberType NoteProperty -Name "AADDeviceID" -Value "$AADDeviceID" -Force $temparray | Add-Member -MemberType NoteProperty -Name "DisplayName" -Value "$($Setting.DisplayName)" -Force $temparray | Add-Member -MemberType NoteProperty -Name "CurrentValue" -Value "$($Setting.CurrentValue)" -Force $temparray | Add-Member -MemberType NoteProperty -Name "DefaultValue" -Value "$($Setting.DefaultValue)" -Force $BiosArray += $temparray } } elseif ($ComputerManufacturer -match 'Lenovo') { # Get Lenovo BIOS settings $BiosSettings = Get-WmiObject -Namespace "root\wmi" -Class "Lenovo_BiosSetting" -ErrorAction SilentlyContinue $BiosArray = @() foreach ($Setting in $BiosSettings) { $temparray = new-object -TypeName PSObject ### to be determined ### $BiosArray += $temparray } } return $BiosArray } |