Azure Can';t从代码运行ps脚本。执行政策问题
我在Azure中有WebApp和Webjob。我的webjob尝试使用Azure Can';t从代码运行ps脚本。执行政策问题,azure,powershell,Azure,Powershell,我在Azure中有WebApp和Webjob。我的webjob尝试使用powershell.Create()然后ps.AddScript(script)和ps.Invoke()运行一些powershell脚本。 在我的本地环境中,webjob运行良好,所有ps脚本都正确执行。但在Azure webjobs中,会引发以下失败: 发生了一个或多个错误。(无法加载文件D:\local\Temp…\Login.ps1,因为在此系统上禁用了运行脚本。有关详细信息,请参阅关于\u执行\u策略 之后,我尝试将
powershell.Create()
然后ps.AddScript(script)
和ps.Invoke()
运行一些powershell脚本。
在我的本地环境中,webjob运行良好,所有ps脚本都正确执行。但在Azure webjobs中,会引发以下失败:
发生了一个或多个错误。(无法加载文件D:\local\Temp…\Login.ps1,因为在此系统上禁用了运行脚本。有关详细信息,请参阅关于\u执行\u策略
之后,我尝试将执行策略设置为urestricted,但此命令在azure控制台中不起作用
我目前的执行政策:
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine RemoteSigned
我尝试了以下方法来更改执行策略(我在azure portal console中运行所有命令):
但我不知道如何以管理员身份在Azure中运行控制台
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
Set-Executionpolicy : The specified registry key does not exist.
At line:1 char:1
+ Set-Executionpolicy -Scope CurrentUser -ExecutionPolicy UnRestricted
如何在Azure中更改ExecutionPolicy?或者如何避免禁用ps脚本的问题?
请帮帮我!)Azure Shell(我想你是指Azure门户控制台)与你的Azure应用程序服务无关。您尝试过吗?您是否可以尝试使用
-ExecutionPolicy Bypass
启动powershell?
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
Set-Executionpolicy : The specified registry key does not exist.
At line:1 char:1
+ Set-Executionpolicy -Scope CurrentUser -ExecutionPolicy UnRestricted