Skip to content

Instantly share code, notes, and snippets.

@ishu3101
Created September 28, 2022 01:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ishu3101/8d1e634f38d3174c0ea6417791c2bb1b to your computer and use it in GitHub Desktop.
Save ishu3101/8d1e634f38d3174c0ea6417791c2bb1b to your computer and use it in GitHub Desktop.
How to Get Computer Information such as CPU, Manufacturer, Model, OS etc using Powershell
# Get Free & Total Disk Space
Get-WmiObject -Class win32_logicaldisk -ComputerName $computerName | ft DeviceID, @{Name="Free Disk Space (GB)";e={$_.FreeSpace /1GB}}, @{Name="Total Disk Size (GB)";e={$_.Size /1GB}} -AutoSize
# Get Computer Model
Get-ComputerInfo | Select -ExpandProperty CsModel
# Get OS
Get-ComputerInfo | Select WindowsProductName
Get-WMIObject win32_operatingsystem | select Caption, OSArchitecture, Version
# Get Computer Manufacturer
Get-WMIObject Win32_ComputerSystem | Select -ExpandProperty Manufacturer
# Get CPU Information
(Get-WmiObject Win32_Processor).Name
# Get Computer Name
hostname
# Get Total Memory
(Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property capacity -Sum).sum /1gb
netsh wlan show profiles) | Select-String "\:(.+)$" | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)} | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -Wrap
# Get Disk Space
Get-WmiObject Win32_LogicalDisk | Select DeviceID,@{Name="GB_Total";Expression={[Math]::Round(($_.Size/1GB),2)}},@{Name="GB_Free";Expression={[Math]::Round(($_.FreeSpace/1GB),2)}},@{Name="%_Used";Expression={[Math]::Round((($_.Size-$_.FreeSpace)/($_.Size)*100),2)}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment