这篇文章主要介绍了在cmd中直接运行PowerShell脚本文件的方法,本文给出了两个小技巧实现在cmd中直接运行PowerShell脚本,需要的朋友可以参考下:

以前在cmd中执行powershell,我们都是这样:

 
PowerShell.exe -file a.ps1


现在想在cmd中这样执行:


a.ps1


此时需要将Powershell脚本的默认打开方式选择为Powershell.exe,可以鼠标右键操作。


也可以使用下面的cmd以管理员权限打开,然后运行命令:


ftype Microsoft.Powershellscript.1="%SystemRoot%\system32\windowspowershell\v1.0\powershell.exe" "%1"
02-06 07:18
查看更多