Skip to content

Instantly share code, notes, and snippets.

@techthoughts2
Created December 28, 2015 15:49
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/6cc6db3985c26d58a988 to your computer and use it in GitHub Desktop.
Save techthoughts2/6cc6db3985c26d58a988 to your computer and use it in GitHub Desktop.
Get general device information loaded up
<#
.Synopsis
Get-GeneralInfo gathers general info about the device to provide in the output
.DESCRIPTION
Get-GeneralInfo gathers general info about the device including hostname, model to display in the final output
#>
function Get-GeneralInfo {
#--------------------------------------------------------------------------------------
#Getting the host name with error control
try{
$Script:hostname = Get-WMIObject Win32_ComputerSystem | Select-Object -ExpandProperty name
}
catch
{
$Script:hostname = "ERROR - Could not determine"
$Script:QC = $false
}
#--------------------------------------------------------------------------------------
#Getting the manufacturer with error control
try{
$manufacturer = Get-CimInstance CIM_ComputerSystem
$Script:manufacturer = $manufacturer.Manufacturer
}
catch
{
$Script:manufacturer = "ERROR - Could not determine"
$Script:QC = $false
}
#--------------------------------------------------------------------------------------
#Getting the model with error control
try{
$model = Get-CimInstance CIM_ComputerSystem
$Script:model = $model.Model
}
catch
{
$Script:model = "ERROR - Could not determine"
$Script:QC = $false
}
#--------------------------------------------------------------------------------------
#getting CPU with error control
try{
$cpu = Get-CimInstance CIM_Processor
$Script:cpu = $cpu.Name
}
catch
{
$Script:cpu = "ERROR - Could not determine"
$Script:QC = $false
}
#--------------------------------------------------------------------------------------
#Get Operating System Info
try{
$sOS =Get-WmiObject -class Win32_OperatingSystem
foreach($sProperty in $sOS){
$Script:OS = $sProperty.Caption
}
}
catch
{
$Script:OS = "ERROR - Could not determine"
$Script:QC = $false
}
#--------------------------------------------------------------------------------------
#Getting the RAM with error control
try{
$RAM = Get-CimInstance CIM_ComputerSystem
$Script:ram = $RAM.TotalPhysicalMemory/1GB
}
catch
{
$Script:ram = "ERROR - Could not determine"
$Script:QC = $false
}
#--------------------------------------------------------------------------------------
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment