當伺服器理面有多個執行SSIS 封裝的 Dtexec.exe在執行時, 假設有個封裝執行太久或其他特殊原因,需要 kill 掉。要如何辨別這些 Process 所執行的內容呢?

透過工作管理員雖可簡單辨別處理序識別碼,但無法取得執行內容

image

 

透過Powershell 搭配WMI 可查詢相關細節,程式碼範例如下

 

# 取得伺服器正在執行的 dtexec.exe (SSIS封裝)
#format-table,可以將輸出結果改以表格的方式呈現
param
(
    [string]$HostName="Sandy-PC"
)
gwmi Win32_process  -ComputerName $HostName | ?{$_.ProcessName -eq 'dtexec.exe'} | select-object -property processId,`
@{Name='PackageName'; Expression={$_.CommandLine.substring($_.CommandLine.toUpper().IndexOf('/F')`
+2,($_.CommandLine.toUpper().indexOf('.DTSX')-$_.CommandLine.toUpper().IndexOf('/F')-2)).trim()+'.dtsx'}}, `
threadCount, WS,VM,CommandLine  | format-table -auto

 

 

image

 

#out-file 將結果輸出文字擋
gwmi Win32_process | ?{$_.ProcessName -eq 'dtexec.exe'} | select-object -property processId,`
@{Name='PackageName'; Expression={$_.CommandLine.substring($_.CommandLine.toUpper().IndexOf('/F')`
+2,($_.CommandLine.toUpper().indexOf('.DTSX')-$_.CommandLine.toUpper().IndexOf('/F')-2)).trim()+'.dtsx'}}, `
threadCount, WS,VM,CommandLine  | out-file "D:\SSIS\test\Integration Services 專案1\Integration Services 專案1\log.txt"

 

參考:http://vsteamsystemcentral.com/cs21/blogs/steve_fibich/archive/2008/08/31/dtexec-exe-what-are-you-doing.aspx

arrow
arrow
    全站熱搜

    小草 發表在 痞客邦 留言(0) 人氣()