I am trying to run a powershell script using Startup in a Group Policy. I have mapped the script in Powershell Scripts Tab under Startup section of the GPO. 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.
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.