Este é o meu comando do powershell: powershell -noprofile -NonInteractive -Command "(gwmi win32_process | select ProcessID,ParentProcessID,@{e={$_.GetOwner().User}}, CommandLine) | ft -AutoSize"
Quando eu executo, recebo a seguinte saída
C:\Users\Administrator>powershell -noprofile -NonInteractive -Command "(gwmi win32_process | select ProcessID,ParentProcessID,@{e={$_.GetOwner().User}}, CommandLine) | ft -AutoSize"
ProcessID ParentProcessID $_.GetOwner().User CommandLine
--------- --------------- ------------------ -----------
0 0
4 0
236 4 SYSTEM
332 320 SYSTEM
384 320 SYSTEM wininit.exe
392 376 SYSTEM
420 376 SYSTEM winlogon.exe
476 384 SYSTEM
484 384 SYSTEM C:\Windows\system32\lsass.exe
544 476 SYSTEM C:\Windows\system32\svchost.exe -k DcomLaunch
584 476 NETWORK SERVICE C:\Windows\system32\svchost.exe -k RPCSS
680 420 DWM-1 "dwm.exe"
...
1256 1176 Administrator "C:\cygwin64\bin\mintty.exe" -i /Cygwin-Terminal.ico -
3052 3000 Administrator \??\C:\Windows\system32\conhost.exe 0x4
2760 2856 Administrator "C:\cygwin64\bin\bash.exe"
2104 1176 Administrator "C:\Windows\system32\cmd.exe"
1504 2104 Administrator \??\C:\Windows\system32\conhost.exe 0x4
2440 1108 Administrator "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
1268 2440 Administrator "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --type=gpu-process --channel="2440.0.15...
2472 2440 Administrator "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --type=renderer --enable-deferred-image...
1496 2440 Administrator "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --type=renderer --enable-deferred-image...
2640 2840 user001 C:\Windows\system32\cmd.exe /c c:\windows\temp\tmpyaoyv0.bat
1040 2640 user001 \??\C:\Windows\system32\conhost.exe 0x4
Eu quero poder filtrar o user001
process
Se eu usar where-object , recebo este erro:
+ ... where-object {$.e -eq user001} | ft -AutoSize
+ ~~~
+ CategoryInfo : ObjectNotFound: ($.e:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Se eu usar onde , eu tenho isso:
}}, CommandLine) | where $_.GetOwner().User -eq 'user001' | ft -AutoSize"
You cannot call a method on a null-valued expression.
At line:1 char:1
+ (gwmi win32_process | select ProcessID,ParentProcessID,@{e={$_.GetOwner().User}} ..
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Então, qual é a maneira correta de filtrar $_.GetOwner().User
?