【发布时间】:2021-10-17 22:20:54
【问题描述】:
尝试启动数组中列出的进程,然后获取这些进程并将它们输出到文件并关闭进程。除了将数组中列出的所有进程填充到输出文件中之外,一切正常。我只拿回一个。
# Array to iterate and open the following
$array2 = "notepad", "iexplore", "mspaint"
# Iterate through array and start process
foreach($process in $array){
Start-Process $process
}
# Query process and output to text file then stop processes
foreach($process in $array){
get-process $array | Out-File process.txt
Stop-Process -Name $process
}
【问题讨论】:
标签: arrays powershell