Get the remote machine OS version with PowerShell
Objective : To find OS version of the remote computer from local machine PowerShell .
Solution1 – Get-wmiobject cmdlet is available in PowerShell to get the info from remote computer .
Get-WmiObject -Class Win32_OperatingSystem -Namespace root/cimv2 -ComputerName ‘remoteip_or_hostname’
Example
Get-WmiObject -Class Win32_OperatingSystem -Namespace root/cimv2 -ComputerName '192.185.62.70' |fl -Property caption,version,buildnumber Get-WmiObject -Class Win32_OperatingSystem -Namespace root/cimv2 -ComputerName 'john-pc' |fl -Property caption,version,buildnumber
Solution2 – Another one-line cmdlet solution is based on wmic to get the info. This cmdlet also works on command prompt (cmd).
wmic /node: <ipaddress> os get caption
Example wmic /node: 192.168.2.70 os get caption
- Both the commands support only if OS of the remote computer is windows and RPC service is running on the remote computer.
- BONUS: To get the the OS info copied to your clipboard, use ‘ |clip’ at end of the command. “wmic /node: 192.168.2.70 os get caption |clip”. Also read : Copy the PowerShell output to clipboard
Great! Useful to me.