All the available cmdlets related to processes can be found by executing the following cmdlet:
Get-Command *process* -CommandType "cmdlet"
Get-Process
To get a list of processes running on the local computer, execute the following command:
Get-Process
To query all the properties or methods available in the Get-Process cmdlet:
Get-Process |Get-Member –MemberType properties
Get-Process |Get-Member –MemberType methods
To get information about priority, location of the executable, the CPU, and memory usage:
Get-Process –Name "sql*" | Format-List ProcessName, Id, BasePriority,PriorityClass, PriorityBoostEnabled, MachineName, Path, UserProcessorTime,PrivilegedProcessorTime, Threads, WorkingSetSize, PagedSystemMemorySize,PrivateMemorySize, VirtualMemorySize
To change the priority of the SQLAGENT.exe process just shown from Normal to High:
$sqlagent=Get-Process -ProcessName "SQLAgent"
$sqlagent | select BasePriority, PriorityClass
$sqlagent.PriorityClass="High"
$sqlagent | select BasePriority, PriorityClass
Stop-Process
To stop SQL Server–related processesusing Stop-Process by executing the following command:
Get-Process "SQL*" Stop-Process -ProcessName "SQL*" -Confirm
To kill the process by the unique process ID:
Get-Process -ProcessName sqlservr | Select-Object ID, ProcessName
Stop-Process 2308
To access the processes from a remote computer:
Get-Process -ComputerName "RemoteHostname"