Search code examples
powershellcpuwmifirewallram

Check RAM, CPU usage and Disk space from a remote computer


Using WMI (https://en.wikipedia.org/wiki/Windows_Management_Instrumentation) I wrote a powershell to monitor Ram, CPU and CPU usage of a remote computer like the following:

$CompObject =  Get-WmiObject -Class WIN32_OperatingSystem -ComputerName $remotePcName
$Memory = ((($CompObject.TotalVisibleMemorySize - $CompObject.FreePhysicalMemory)*100)/ $CompObject.TotalVisibleMemorySize) 

The computers are connected to the same network and can possibly be joined into the same Domain. My question is: can a firewall somehow block the execution of my powershell and prevent me from being able to calculate the value of a resource on a remote computer? If so, which firewall rule should I change?


Solution

  • can a firewall somehow block the execution of my powershell and prevent me from being able to calculate the value of a resource on a remote computer?

    Yes!

    If so, which firewall rule should I change?

    Get-WmiObject will default to WMI-over-RPC for remote transport, so you'll want to follow the guidance for allowing WMI remoting on networked Windows computers.

    As of writing, the rule group in question is named Windows Management Instrumentation (WMI):

    Get-NetFirewallRule -DisplayGroup 'Windows Management Instrumentation (WMI)'