我编写了一个PowerShell脚本来安装和启动一些服务.它仅在脚本以管理员身份运行时才有效.有没有办法强制脚本拥有这些权限?
如果您使用的是PowerShell V2,您还可以执行以下操作:
Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "Get-Service"'
Run Code Online (Sandbox Code Playgroud)
这将以管理员身份运行"Get-Service",您可以将其替换为您的脚本.
| 归档时间: |
|
| 查看次数: |
14768 次 |
| 最近记录: |