Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure Can';t从代码运行ps脚本。执行政策问题_Azure_Powershell - Fatal编程技术网

Azure Can';t从代码运行ps脚本。执行政策问题

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策略 之后,我尝试将

我在Azure中有WebApp和Webjob。我的webjob尝试使用
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