作为一个云计算领域的专家,我建议使用以下方法来启动Powershell脚本:
powershell
命令来启动Powershell。例如:powershell -File script.ps1
Start-Process
命令来启动Powershell脚本。例如:Start-Process powershell -ArgumentList "-File script.ps1"
Invoke-Command
命令来启动Powershell脚本。例如:Invoke-Command -ScriptBlock { & 'script.ps1' }
Start-Job
命令来启动Powershell脚本。例如:Start-Job -ScriptBlock { & 'script.ps1' }
需要注意的是,这些方法都需要在Powershell中运行,而不是在批处理文件中运行。如果需要在批处理文件中运行Powershell脚本,可以使用以下方法:
powershell
命令来启动Powershell脚本。例如:powershell -File script.ps1
Start-Process
命令来启动Powershell脚本。例如:Start-Process powershell -ArgumentList "-File script.ps1"
Invoke-Command
命令来启动Powershell脚本。例如:Invoke-Command -ScriptBlock { & 'script.ps1' }
Start-Job
命令来启动Powershell脚本。例如:Start-Job -ScriptBlock { & 'script.ps1' }
需要注意的是,在批处理文件中运行Powershell脚本需要使用powershell
命令或Start-Process
命令,而不是直接运行Powershell脚本。
领取专属 10元无门槛券
手把手带您无忧上云