跳至内容
龙讯旷腾 pwmat Wiki
用户工具
注册
登录
站点工具
搜索
工具
显示页面
过去修订
全部折叠/展开
反向链接
最近更改
媒体管理器
网站地图
注册
登录
>
中文
最近更改
媒体管理器
网站地图
您的足迹:
en:pwstudio:qa:q105
本页面只读。您可以查看源文件,但不能更改它。如果您觉得这是系统错误,请联系管理员。
~~NOTOC~~ ===== q105: Running a PowerShell script fails on Windows ===== If you run into an error like this while running a script: <wrap hi> File cannot be loaded because running scripts is disabled on this system. </wrap> <WRAP lo> ==== Specific symptom ==== </WRAP> <code Powershell> > .\get_hdwkey.ps1 .\get_hdwkey.ps1 : File C:\Users\lxkt\Desktop\PWmatLICENSE_win\get_hdwkey.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1 + .\get_hdwkey.ps1 + ~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess PS C:\Users\lxkt\Desktop\PWmatLICENSE_win> </code> (The ''lxkt'' in the path above is just the username on the example computer — your own computer will show your own username, which is normal and unrelated to the cause of the error.) This happens because Windows, for security reasons, disables running unsigned PowerShell scripts by default. It's a very common situation — just follow the steps below to fix it. <WRAP em> ==== Fix ==== </WRAP> Method 1: Change the execution policy (recommended — fixes it once and for all) <wrap em>Run PowerShell as administrator</wrap> (search for PowerShell in the Start menu, right-click it, and choose "Run as administrator"), then run: <code Powershell> # Allow running local scripts Set-ExecutionPolicy RemoteSigned -Scope CurrentUser # You'll need to type ''Y'' to confirm or Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force </code> After running the first command, if it asks for confirmation, type ''Y'' and press Enter; or you can use the second command with ''-Force'', which confirms automatically without asking. Once this is set, open a new terminal window (doesn't need to be administrator) and run the original script again — it should work normally. Method 2: Bypass temporarily (this run only) If you'd rather not change the system setting permanently, you can bypass it just for this one run instead: <code Powershell> powershell -ExecutionPolicy Bypass -File .\get_hdwkey.ps1 or powershell -ExecutionPolicy Unrestricted -File .\get_hdwkey.ps1 </code> Note that this only applies to this one run — the next time you run a different script, you may hit the same error again. If that's annoying, we'd recommend using Method 1 to fix it once and for all. ~~DISCUSSION:off~~
en/pwstudio/qa/q105.txt
· 最后更改: 2026/08/04 01:22 由
127.0.0.1
页面工具
显示页面
过去修订
反向链接
全部折叠/展开
回到顶部