[英]Error: CallDepthOverflow when running Powershell startup scripts using Group Policy
I am trying to run a powershell script using Startup in a Group Policy.我正在尝试使用组策略中的启动来运行 powershell 脚本。 I have mapped the script in Powershell Scripts Tab under Startup section of the GPO.
我已将脚本映射到 GPO 启动部分下的 Powershell 脚本选项卡中。 The script contains a one liner command to set the TimeZone information.
该脚本包含一条用于设置时区信息的单行命令。 Below is the code:
下面是代码:
Set-TimeZone -Id "India Standard Time"
Below is the error msg:以下是错误消息:
Error Message = The script failed due to call depth overflow.
Fully Qualified Error ID = CallDepthOverflow
Context:
Severity = Warning
Host Name = ConsoleHost
Host Version = 5.1.17763.592
Host ID = 836b5c03-9d27-402c-b8da-a169188ff709
Host Application = -ExecutionPolicy ByPass -File Set-TimeZone.ps1
Engine Version = 5.1.17763.592
Runspace ID = 23e7e0db-3eb1-404c-828d-aefbd89b8e01
Pipeline ID = 1
Command Name =
Command Type =
Script Name =
Command Path =
Sequence Number = 26
User = LION\SYSTEM
Connected User =
Shell ID = Microsoft.PowerShell
The command works when I run the command manually.当我手动运行命令时,该命令有效。
Thanks, Rajiv谢谢,拉吉夫
The problem you encounter comes from the fact that you have named your script file with the same name of the cmdlet you are trying to execute .您遇到的问题来自于您使用与您尝试执行的 cmdlet 相同的名称来命名您的脚本文件。
Now the script is calling itself time and again..现在脚本一次又一次地调用自己..
Rename your script file into something like Set-IndiaTimeZone.ps1
so it is not the name of a cmdlet you are using inside the script and it should work as expected.将您的脚本文件重命名为类似
Set-IndiaTimeZone.ps1
的名称,这样它就不是您在脚本中使用的 cmdlet 的名称,它应该可以按预期工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.