简体   繁体   English

错误:使用组策略运行 Powershell 启动脚本时出现 CallDepthOverflow

[英]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.

相关问题 如何修复在 Windows 10 上运行 NPM RUN 脚本的组策略错误 - How can I fix a group policy error running NPM RUN scripts on Windows 10 从 Java 调用 PowerShell 时偶尔出现 Windows 权限错误 - “运行脚本已禁用” - occasional Windows permission error when calling PowerShell from Java - "running scripts disabled" 无法使用 Powershell 将组策略(本地 gpo)状态更新为“未配置” - Unable to update group policy(local gpo) status to "Not Configured" using Powershell 在Windows 7上从启动文件夹运行多个脚本 - Running Multiple Scripts from Startup Folder on Windows 7 运行非PowerShell脚本的C#PowerShell - C# PowerShell running non PowerShell scripts 有没有办法以编程方式将启动脚本添加到本地组策略? - Is there any way to programmatically add a startup script to the local group policy? 使用 Powershell 通过 npm 脚本运行 Jest 测试时,转义引号和斜杠的正确方法是什么? - What is the proper way to escape quotes and slashes when running a Jest test with --collectCoverageFrom from Powershell via npm scripts? 使用Powershell时出现JDWP语法错误 - JDWP syntax error when using Powershell 使用VBScript查询本地组策略 - Querying Local Group Policy using VBScript 为什么设置执行策略权限时PowerShell会引发注册表访问错误? - Why PowerShell threw registry access error when setting execution policy rights?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM