Original article address:Http://app.en25.com/e/es.aspx? S = 1403 & E = 5287 & elq = ffdaeb1db50d44cd98829640038cf0d4
Original article:
If you need to filter running processes by owner, for example to terminate the ones owned by some user, you shoshould Use wmi and the getowner () method. this code will retrieve all processes from a local or remote system and add an owner property, which you can then use to select or filter processes:
Get-wmiobject Win32_process | Foreach-Object { $ Ownerraw = $ _. Getowner () ; $ Owner = '{0} \ {1 }' -F $ Ownerraw . Domain , $ Ownerraw . User ; $ _ | Add-member Noteproperty owner $ Owner -Passthru } | Select-Object Name , Owner
Note that you can get Owner information for other users only when you have admin privileges.
Translation:
If you want to filter running processes based on the process owner, for example, you can useWMIOfGetowner ()Method. The followingCodeIt will retrieve information about all local or remote processes and add themOwnerAttribute, you can select and filter the process based on this:
Get-wmiobject Win32_process | Foreach-Object { $ Ownerraw = $ _. Getowner () ; $ Owner = '{0} \ {1 }' -F $ Ownerraw . Domain , $ Ownerraw . User ; $ _ | Add-member Noteproperty owner $ Owner -Passthru } | Select-Object Name , Owner
Note that when you have the Administrator permission, you can also obtain other information about the process user. [Question]
Notes:
Suitable for killing processes based on the owner and troubleshooting virus processes.