Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, November 17, 2011 9:48 AM
Hi, when i do a
get-process -computername abcde
the CPU-column is always empty. Is it supposed to be like that or am i doing something wrong?
Thanks, rob
All replies (11)
Thursday, November 17, 2011 11:25 PM ✅Answered | 1 vote
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.totalprocessortime.aspx
You are attempting to access the TotalProcessorTime property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.
Friday, November 18, 2011 5:56 AM ✅Answered
I can't reproduce the sentence because I need to provide credentials or at least that is what I though
>>Get-Process -ComputerName 192.168.1.36Get-Process : Couldn't connect to remote machine.
At line:1 char:1
- Get-Process -ComputerName 192.168.1.36
+ CategoryInfo : NotSpecified: (:) [Get-Process], InvalidOperationExcept
ion
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.C
ommands.GetProcessCommandSo instead i use the Invoke-command cmdlet, passing the necessary credential:
>> Invoke-Command -ScriptBlock {get-process} -ComputerName 192.168.1.36 -Credential (get-credential)Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName PSComputerNa
e
--
118 5 14896 13520 43 2008 audiodg 192.168.1.36
71 7 5424 9136 63 0.38 1520 calc 192.168.1.36
721 6 1340 3052 35 3.32 416 csrss 192.168.1.36
167 5 1096 4000 33 0.52 1324 csrss 192.168.1.36
...and the result shows correctly the cpu usage, you could try this command.
You are using two different remote methods. The PsRemoting (needed powershell V2 on the both machines) doesn't same that native .Net method(no need powershell on the remote machine).
Thursday, November 17, 2011 9:55 AM | 1 vote
I've not noticed it before, but I've tried it on a few remote machines, normal and elevated, and I concur: The CPU column is empty.[string](0..9|%{[char][int](32+("39826578840055658268").substring(($_*2),2))})-replace "\s{1}\b"
Thursday, November 17, 2011 10:39 AM
However, you can retrieve the cpu information from remote machines using the win32_process wmi class:
gwmi -Class win32_process -computername some-pc | select name, kernelmodetime, usermodetime
[string](0..9|%{[char][int](32+("39826578840055658268").substring(($_*2),2))})-replace "\s{1}\b"
Thursday, November 17, 2011 11:12 AM | 2 votes
Here's something that returns something a bit more useable. (I'm bored, ok, Michal!)
Get-WmiObject Win32_Process |
select Name, @{Name="CPU_Time";
Expression={$_.kernelmodetime + $_.usermodetime}} | sort CPU_Time -Descending
[string](0..9|%{[char][int](32+("39826578840055658268").substring(($_*2),2))})-replace "\s{1}\b"
Thursday, November 17, 2011 2:52 PM
Thanks for your help. I hate to say it, but i knew that. :)
But the question still remains why get-process doesn't work. At least i know its not just in my test environment.
rob
Thursday, November 17, 2011 3:20 PM
When I run it on my local pc with the -computername parameter, it's not blank.
PS C:\scripts> ps -ComputerName grant-pc | sort cpu -Descending
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
--
308 20 16520 9696 164 3 340.57 7028 vpc
115 11 3148 2116 90 3 079.26 3556 WPN111
1052 38 49548 31000 218 2 378.50 3716 MTN Online
984 86 90660 79824 320 966.93 2816 wmplayer
12613 276 204852 208332 880 594.91 4872 OUTLOOK etc...
[string](0..9|%{[char][int](32+("39826578840055658268").substring(($_*2),2))})-replace "\s{1}\b"
Thursday, November 17, 2011 3:26 PM
And, I might add, I've just tested it with Powershell Ver. 3.0, and the issue is the same - blank cpu column when querying remote machines. So it hasn't been fixed. I don't know if this is by design for some reason perhaps.[string](0..9|%{[char][int](32+("39826578840055658268").substring(($_*2),2))})-replace "\s{1}\b"
Friday, November 18, 2011 3:07 AM
I can't reproduce the sentence because I need to provide credentials or at least that is what I though
>>Get-Process -ComputerName 192.168.1.36
Get-Process : Couldn't connect to remote machine.
At line:1 char:1
- Get-Process -ComputerName 192.168.1.36
-
+ CategoryInfo : NotSpecified: (:) [Get-Process], InvalidOperationExcept
ion
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.C
ommands.GetProcessCommand
So instead i use the Invoke-command cmdlet, passing the necessary credential:
>> Invoke-Command -ScriptBlock {get-process} -ComputerName 192.168.1.36 -Credential (get-credential)
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName PSComputerNa
e
--
118 5 14896 13520 43 2008 audiodg 192.168.1.36
71 7 5424 9136 63 0.38 1520 calc 192.168.1.36
721 6 1340 3052 35 3.32 416 csrss 192.168.1.36
167 5 1096 4000 33 0.52 1324 csrss 192.168.1.36
...
and the result shows correctly the cpu usage, you could try this command.
Thursday, August 3, 2017 1:42 PM
The following will get you all the info:
Invoke-Command -ComputerName abcde { Get-Process }
Thursday, August 3, 2017 1:49 PM
Please do not reactivate ancient threads. Especially when they have been answered long time ago.
Grüße - Best regards
PS:> (79,108,97,102|%{[char]$_})-join''