PoshCode Archive  Artifact Content

Artifact 59e3559ac4d69dfc6900830606a4a30628a00cf079d2f84e2fd357c633db3d74:

  • File show-sqlprocesses.ps1 — part of check-in [5131b10ce9] at 2018-06-10 13:41:22 on branch trunk — # (user: Rob Sewell size: 1270)

# encoding: utf-8
# api: powershell
# title: show-sqlprocesses
# description: #
# version: 0.1
# type: function
# author: Rob Sewell
# license: CC0
# function: Show-SQLProcesses
# x-poshcode-id: 4464
# x-archived: 2014-08-18T21:33:42
# x-published: 2014-09-12T09:47:00
#
# NAME: Show-SQLProcesses.ps1
# AUTHOR: Rob Sewell http://sqldbawithabeard.com
# DATE:06/08/2013
# #
# COMMENTS: Load function for Showing Processes on a SQL Server
# 覧覧覧覧覧覧覧覧覧覧覧覧
#
  #############################################################################################
#
# NAME: Show-SQLProcesses.ps1
# AUTHOR: Rob Sewell http://sqldbawithabeard.com
# DATE:06/08/2013
#
# COMMENTS: Load function for Showing Processes on a SQL Server
# 覧覧覧覧覧覧覧覧覧覧覧覧

Function Show-SQLProcesses ($SQLServer)

{
$server = new-object "Microsoft.SqlServer.Management.Smo.Server" $SQLServer
$Server.EnumProcesses()|Select Spid,BlockingSpid, Login, Host,Status,Program,Command,Database,Cpu,MemUsage |Format-Table -wrap -auto

$OUTPUT= [System.Windows.Forms.MessageBox]::Show("Do you want to Kill a process?" , "Question" , 4) 

if ($OUTPUT -eq "YES" ) 
{

$spid = Read-Host "Which SPID?"
$Server.KillProcess($Spid)


} 
else 
{ 

}

}