PowerShell Get-Counter not working on Remote Computer RRS feed

All replies

  • Works fine for me if we use the computer name:

    PS C:\scripts> $listOfMetrics = @(
    >>      "\processor(0)\% processor time",
    >>      "\processor(1)\% processor time"
    >> )
    PS C:\scripts> Get-Counter $listOfMetrics -ComputerName WS701
    Timestamp                 CounterSamples
    ---------                 --------------
    5/22/2017 1:37:17 AM      \\ws701\\processor(0)\% processor time :
                              \\ws701\\processor(1)\% processor time :


    Monday, May 22, 2017 5:38 AM
  • # we can even do this:
    $listOfMetrics = @(
    	'\Memory\Available MBytes',
    	'\processor(0)\% processor time',
    	'\processor(1)\% processor time'
    Get-Counter $listOfMetrics -ComputerName WS701,WS702
    #or this:
    Get-Counter $listOfMetrics -ComputerName WS701,WS702 | select -expand countersamples


    Monday, May 22, 2017 5:43 AM
  • Thanks for the quick response. I am facing below when passing local computer name in this command.

    Get-Counter $listOfMetrics -ComputerName computer1

    Get-Counter : Unable to connect to the specified computer or the computer is offline.

    In case I provide remote computer name, I am getting below error.

    Get-Counter : Unable to access the desired computer or service. Check the permissions and  authentication of the log service or the interactive user session against  those on the computer or service being monitored.

    Both the computers are on same domain and I am the admin for both. local computer is having win 8.1 and remote is having win 2008 R2. Both are 64 bit OS and PowerShell 4.0 has been installed on both. Pls let me know if any other setting is missing.

    Regards, Parveen

    Monday, May 22, 2017 6:35 AM
  • Firewall or counters are not running.


    Monday, May 22, 2017 6:38 AM
  • Counters are running and I am getting all the performance counters properly when running below command on local without passing computername parameter e.g.

    Get-Counter $listOfMetrics

    It seems there is some issue here.

    Regards, Parveen

    • Edited by Parveen Singla Monday, May 22, 2017 6:52 AM updated command
    Monday, May 22, 2017 6:52 AM
  • That is correct.  You cannot authenticate to the local system o Windows 8 and later without making special arrangements.  You must skip it.

    Be sure port 445 is open and allows the local system to connect back through the firewalls port. 


    Monday, May 22, 2017 7:01 AM
  • Port 445 is open. Also tried by disabling firewall but still getting same error.

    Regards, Parveen

    Monday, May 22, 2017 8:18 AM