PowerShell custom module call crashing PowerShell session
Hey,
Currently running into an issue with a custom PowerShell script that I own.
The script has been in production almost daily for the past 4-5 years but the past couple weeks it's been erroring out on me for reasons I don't understand. The script in question is an AD mgmt script which checks 800+ users and updates, deactivates and creates users based on a master data file which is imported from our payroll system.
The script crashes, along with the PS session every time when the script hits a specific point, which is running a custom module that runs through and deactivates a list of AD users that are to be terminated. I'm unsure if it's the module or the script crashing, as some times the script will continue, even if only for a couple lines longer after the crash point has been hit. The custom module that is called at this line has been tested, on the same server but does work as expected, even when ran with actual data (similar to the conditions when ran as part of the script.)
Does anyone here know where i should start? I've attempted the following:
- Checking event logs to see if anything useful is logged there (which there sadly didn't seem to be)
- DISM scans and SFC scans + reboots
- Running script in ISE, as scheduled task and in regular terminal
- Seperating the (assumed) faulty module into seperate test environment, and successfully ran it
- Checking the same module for unprintable ASCII characters
- Checking the specific lines calling the custom module for unprintable ASCII
Any help would be much appreciated, as the script is assumed to be business critical.