小编KR4*_*STL的帖子

Windows Powershell 策略执行绕过

我一直在创建一个 powershell 脚本来帮助我在不同用户的 PC 上自动执行任务,我遇到了一个问题,我必须手动允许脚本在每台 PC 上运行,然后才能执行它。

我尝试使用我找到的各种解决方案,但到目前为止似乎都不起作用。

我尝试过作为批处理文件的解决方案(理想情况下,我希望批处理文件下载脚本(已经对此进行排序),然后打开 powershell 脚本并成功绕过此问题):

powershell.exe -executionpolicy bypass -windowstyle hidden -noninteractive -nologo -file "multitool.ps1"
Run Code Online (Sandbox Code Playgroud)
powershell -command "& {Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force}"
Run Code Online (Sandbox Code Playgroud)
    @echo off
reg add HKLM\system32\windows\microsoft\powershell\1\shellids\microsoft.powershell /v "Path" /d "c:\windows\system32\windowspowershell\v1.0\powershell.exe"
reg add HKLM\system32\windows\microsoft\powershell\1\shellids\microsoft.powershell /v "ExecutionPolicy" /d "unrestricted"
Run Code Online (Sandbox Code Playgroud)
@echo off
regedit /s file.reg
Run Code Online (Sandbox Code Playgroud)

其中 file.reg 包含以下内容:

[hkey_local_machine\system32\windows\microsoft\powershell\1\shellids\microsoft.powershell] 
"Path"="c:\windows\system32\windowspowershell\v1.0\powershell.exe"
"ExecutionPolicy"="unrestricted"
Run Code Online (Sandbox Code Playgroud)

运行 powershell 脚本时,所有这些都会导致以下结果:截屏

非常感谢所有帮助

windows powershell batch-file

7
推荐指数
2
解决办法
6万
查看次数

标签 统计

batch-file ×1

powershell ×1

windows ×1