且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PowerShell:运行脚本的执行策略变通方法

更新时间:2023-12-04 19:04:10

要构建 Bill_Stewart 的评论,请使用以下目标创建一个快捷方式,它将允许您运行 PowerShell 脚本:

To build off of Bill_Stewart's comment, create a shortcut with the following target and it will allow you to run a PowerShell script:

 C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -file "\\Server\Path\to\script\script.ps1"

如果你想在远程机器上运行这个命令,你可以在创建上面的快捷方式并将其存储在远程机器可以访问的网络位置之后,始终可以执行这样的操作.

If you want to run this command on a remote machine, you can can always do something like this after creating the above shortcut and storing it somewhere the remote machine can access on the network.

Invoke-Command -computername Computer1 -Scriptblock { Start-process "\\Server\Path\to\shortcut\shortcut.lnk" }