Powershell: Get-Process -Id <root_pid> fails when not running sudo

Created on 17 Aug 2016  路  4Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

Find a process running as root and try to use Get-Process on it when PowerShell was not started w/ sudo, e.g.

Get-Process -Id ((ps -ef | grep ^root | select -first 1 | % { $_ -split ' +' })[1])

Expected behavior

The process object is returned

Actual behavior

PS /etc> Get-Process -Id ((ps -ef | grep ^root | select -first 1 | % { $_ -split ' +' })[1])
Get-Process : Cannot find a process with the process identifier 1.
At line:1 char:1
+ Get-Process -Id ((ps -ef | grep ^root | select -first 1 | % { $_ -spl ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (1:Int32) [Get-Process], ProcessCommandException
    + FullyQualifiedErrorId : NoProcessFoundForGivenId,Microsoft.PowerShell.Commands.GetProcessCommand

Environment data

PS /home/jasonsh/src/PowerShell/tools> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.0-alpha
PSEdition                      Core
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   3.0.0.0
GitCommitId                    v6.0.0-alpha.9
CLRVersion
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
Area-Cmdlets Issue-Bug OS-Linux Resolution-Fixed

Most helpful comment

This seems to be a corefx issue. Filed dotnet/corefx#13135.

All 4 comments

I'm considering this a bug as ps 1 works; so obviously this information is available to non-root users.

This seems to be a corefx issue. Filed dotnet/corefx#13135.

Awesome investigation, thanks @nzubair.

This appears to be fixed.

Was this page helpful?
0 / 5 - 0 ratings