简体   繁体   中英

In Format-Table, how do I remove results with certain words?

I am trying to make a PowerShell that lists every process that isn't required by windows.


What I want:

a table without any processes owned by NT AUTHORITY\SYSTEM (as well as names of said process)


What I'm getting:

a list of every process, name and username


I've tried using cmd, I've tried using TASKLIST (cmdlet), I've tried looking it up but there seems to be nothing about this specifically.

This is the code I'm using:

Get-Process -IncludeUserName | Format-Table -Property Name, UserName

It would also be nice to also get rid of processes like system, that have no "username"

Simply filter the result before your format:

Get-Process -IncludeUserName | Where UserName -ne "NT AUTHORITY\System"  | Format-Table -Property Name, UserName

-ne means Non Equal

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM