Command Line
Networked WMI Operations with PowerShell CIM
Query an authorized remote Windows computer through a CIM session.
Follow the steps in order and stop if the screen or target does not match what is described. Use administrator access only when the task requires it.
Prepare managed remoting
The target must be authorized, reachable, and configured for Windows Remote Management with appropriate firewall and authentication policy.
Create a session
Use an explicit computer name. PowerShell can securely prompt for credentials when required.
Command
$session = New-CimSession -ComputerName PC-NAMERun a read-only query
Pass the session to Get-CimInstance.
Command
Get-CimInstance -CimSession $session -ClassName Win32_OperatingSystem | Select-Object Caption, Version, LastBootUpTimeQuery disk free space
Filter to local disks and select explicit properties.
Command
Get-CimInstance -CimSession $session -ClassName Win32_LogicalDisk -Filter "DriveType=3" | Select-Object DeviceID, Size, FreeSpaceRemove the session
Always close the session when the task is complete.
Command
Remove-CimSession -CimSession $sessionDo not weaken authentication
Do not disable certificate checks, expose WinRM publicly, or add wildcard TrustedHosts entries to make a failed connection work.