Powershell Operating System Queries
# read Windows build number
(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\" -Name UBR).UBR
# Windows uptime
(Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime
# or
Get-CimInstance -ClassName Win32_OperatingSystem | Select LastBootUpTime
# get hostname
[System.Net.Dns]::GetHostName()
# or
$env:computername
# information about windows
Get-ComputerInfo | Select OSname, OStype, OSversion,
OSBuildNumber, OSArchitecture, OSProductType, OSMuiLanguages, OSLastBootUpTime,
OSSystemDrive, OSInstallDate, OSRegisteredUser, CSName
# only on Server versions:
# read the windows components which are installed or removed
Get-WindowsFeature | Where Installed
Get-WindowsFeature | Where InstallState -eq Removed
# W10, as admin, Remote Server Administration Tools, RSAT
Get-WindowsCapability -Name RSAT* -Online | Format-Table Displayname, State
# get windows start/stop events by query the eventlog-service
Get-WinEvent -FilterHashtable @{logname = 'System'; id = 6005, 6006} -MaxEvents 20 | Format-Table -wrap
# get windows start/stop events by query the eventlog-service with details
Get-WinEvent -FilterHashtable @{logname = 'System'; id =
1074, 6005, 6006, 6008, 6009} -MaxEvents 10 | Format-Table -wrap