Skip to content

Instantly share code, notes, and snippets.

@techthoughts2
Last active December 1, 2021 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techthoughts2/d78813d2e7d5d05ba0aa2e2434dcb416 to your computer and use it in GitHub Desktop.
Save techthoughts2/d78813d2e7d5d05ba0aa2e2434dcb416 to your computer and use it in GitHub Desktop.
Basic Info
#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