您的位置:首页 > 运维架构 > Shell

Windows PowerShell and Processes

2012-03-16 13:10 351 查看
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"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: