检查使用"。\ scriptName.ps1"启动的多个powershell脚本运行实例。

时间:2017-11-14 20:58:28

标签: powershell

以下主题解释了如何使用get-wmiobject win32_process检查多个PowerShell脚本实例

Assure only 1 instance of PowerShell Script is Running at any given Time

要使get-wmiobject win32_process列出正在运行的powershell脚本,需要使用powershell.exe scriptName.ps1调用该脚本。如何检查运行使用.\scriptName.ps1调用脚本的脚本的多个实例?

1 个答案:

答案 0 :(得分:-1)

您可以使用以下内容查看结果是否为> 1

(Get-WmiObject Win32_Process | select commandline | where {$_ -ilike "*scriptName.ps1*"} | measure).Count