Last active
December 1, 2021 04:18
-
-
Save techthoughts2/d78813d2e7d5d05ba0aa2e2434dcb416 to your computer and use it in GitHub Desktop.
Basic Info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#get the domain | |
$domain = $env:USERDNSDOMAIN | |
#Get Operating System Info | |
$sOS = Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -ExpandProperty Caption | |
try { | |
$sOS = Get-WmiObject -class Win32_OperatingSystem | |
$Script:OS = $sOS.Caption | |
} | |
catch { | |
$Script:OS = "ERROR - Could not determine the OS version." | |
$Script:QC = $false | |
} | |
#-------------------------------------------------------------------------------------- | |
#Getting the hostname with error control | |
try { | |
$Script:hostname = Get-WMIObject Win32_ComputerSystem | Select-Object -ExpandProperty name | |
} | |
catch { | |
$Script:hostname = "ERROR - Could not determine Hostname." | |
$Script:QC = $false | |
} | |
#-------------------------------------------------------------------------------------- | |
#Getting CPU with error control | |
try { | |
$cpuCores = Get-CimInstance CIM_Processor | |
$Script:CPU = $cpu.Name | |
} | |
catch { | |
$Script:cpu = "ERROR - Could not determine the CPU." | |
$Script:QC = $false | |
} | |
#-------------------------------------------------------------------------------------- | |
#Getting the RAM with error control | |
try { | |
$RAM = Get-CimInstance CIM_ComputerSystem | |
$Script:RAM = [math]::round($RAM.TotalPhysicalMemory / 1GB, 0) | |
} | |
catch { | |
$Script:ram = "ERROR - Could not determine the amount of RAM." | |
$Script:QC = $false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment