简体   繁体   English

获取PowerShell进程的进程ID

[英]get process ID of PowerShell process

How would I know the process ID (PID) of the current PowerShell process? 我如何知道当前PowerShell进程的进程ID(PID)?

Copy-Item \\APPSRVR02\DocExport\*.csv \\APPSRVRWPA\d$\DocImport\ImportFiles\
Remove-Item \\APPSRVRAP02\DocExport\*.csv

Some command to know PID of the process that is executing the above statements. 有些命令知道正在执行上述语句的进程的PID。

Powershell has a concept called Automatic Variables . Powershell有一个名为Automatic Variables的概念。

These are variables which the host defines when it starts up, so if you want to know the ID of the powershell process you are running in you can just type $PID and it will output the ID of the powershell process you are running within. 这些是主机在启动时定义的变量,因此如果您想知道正在运行的powershell进程的ID,只需键入$PID ,它就会输出您正在运行的PowerShell进程的ID。 Depending on what you need the process ID for that should work for you. 根据您的需要,该流程ID应该适合您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM