Skip to content

Instantly share code, notes, and snippets.

@CodyMathis123
Created September 3, 2021 15:14
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 CodyMathis123/34e2062277a22ed4f5076e773784f1d3 to your computer and use it in GitHub Desktop.
Save CodyMathis123/34e2062277a22ed4f5076e773784f1d3 to your computer and use it in GitHub Desktop.
SystemInfo-JSON
$props = @('Name', 'Model', 'Manufacturer', 'Username', 'SystemSKUNumber', 'TotalPhysicalMemory')
$calculatedProps = @{ Name = 'RAM (GB)'; Expression = { [int]($_.TotalPhysicalMemory / 1GB) } }, @{ Name = 'Processor Name'; Expression = { (Get-CimInstance -Query 'SELECT Name FROM Win32_Processor').Name.Trim() } }
$fullPropsToSelect = foreach ($propToSelect in $($props, $calculatedProps)) {
$propToSelect
}
Get-CimInstance -Query "SELECT $($props -Join ',') FROM Win32_ComputerSystem" | Select-Object -Property $fullPropsToSelect -ExcludeProperty TotalPhysicalMemory | ConvertTo-Json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment