[英]How to get process id of process that is triggered by a powershell script
I have a script that has been executed using powershell ISE. 我有一个使用Powershell ISE执行的脚本。 This Invoke-WUInstall seems to trigger powershell.exe.
此Invoke-WUInstall似乎会触发powershell.exe。 How can I capture the process ID for the powershell.exe.
如何捕获powershell.exe的进程ID。
$WUInstallScript = { Get-WUInstall -AcceptAll |Out-File C:\SUPPORT\text.log}
Invoke-WUInstall -ComputerName computername -Script $WUInstallScript -Confirm:$false
You can write it to the log file, and pick it up from there: 您可以将其写入日志文件,然后从此处进行拾取:
$WUInstallScript = { "Process ID is $PID" | Out-File C:\SUPPORT\text.log
Get-WUInstall -AcceptAll | Out-File C:\SUPPORT\text.log -Append}
Invoke-WUInstall -ComputerName computername -Script $WUInstallScript -Confirm:$false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.