VMware Cloud Community
markvm2
Enthusiast
Enthusiast

Tips for running a PowerCLI script continuously? Script stops after several hours.

I have a script that that will constantly pull information from vCenter in a constant loop. I would like to make this a service that Is always running but for some reason the script stops running after several hours. I started running it yesterday around 3PM and it stopped working at 11PM. Has anyone run into a problem with this before? I had another PowerCLI session opened that was not running anything and that had disconnected from vCenter with some error about call depth too high. I am not sure if that is related.

0 Kudos
4 Replies
LucD
Leadership
Leadership

It looks like you are hitting some limits somewhere.

Can you check what is in $error[0] after the script stopped ?

You could also have a look at the vpxd log on the vCenter.

That might contain a clue why a connection was dropped.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
markvm2
Enthusiast
Enthusiast

It looks like it is actually some kind of error with PowerShell. The error is "The script failed due to call depth overflow. The call depth reached 1001 and the max is 1000"

I have a function that loops itself doing a Get-VIEvent each time so maybe that has something to do with it?

0 Kudos
LucD
Leadership
Leadership

Yes, that kind of error is most of the time an endless loop in the script (and trust me, I have seen this several times :smileygrin:).

If you care to share the script, I could have a look.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
CAJason
Contributor
Contributor

I know that this is many months too late, but perhaps it would be more workable to run the script as a scheduled task in windows, with the desired recurrence set up at the task level rather than as a loop within the script.  That way, if there is a problem and the system (or just the script) crashes, the next scheduled run will still fire off a new instance of it.  It would also sidestep this infinite loop detection/protection issue that you're running into.

My deployment notes: http://virtuallyjason.blogspot.com
0 Kudos