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"
CodePudding user response:
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