cmd或powershell以管理员命令执行PowerShell脚本

比如我的脚本路径:C:\script\psfile.ps1

管理员运行powershell来执行psfile.ps1,命令如下:
powershell -noprofile -command "&{ start-process powershell -ArgumentList '-noprofile -file C:\script\psfile.ps1' -verb RunAs}"

 

该命令用CMD或Powershell 均可执行

posted @ 2020-08-26 10:32  IT少年  阅读(4506)  评论(0编辑  收藏  举报