I have a few powershell scripts that are scheduled, and they usually run just fine (both as a scheduled task, and when run manually)
I've got an issue where occasionally, they just stop working midway through a script.
One of my scripts looks like this:
start-transcript
write-host "Starting!"
foreach($blah in $blahblah)
{
write-host " $blah"
}
write-host "Finished"
stop-transcript
Whats odd is that when I look at the transcript I see this pattern:
**********************
Windows PowerShell transcript start
Start time: 20170116055439
Username : domain\user
Machine : PCNAME (Microsoft Windows NT 6.1.7601 Service Pack 1)
**********************
Transcript started, output file is GetMSOLLicensestoCSVTranscript.txt
Starting!
blahitem1
blahitem2
...
blahitem 37675
**********************
Windows PowerShell transcript end
End time: 20170116060001
**********************
Note that it just stopped in the middle of the loop (it wasn't done with all the data) and note that the write-host "Finished" never got called.
What I found interesting was that powershell still somehow closed up the transcript file and wrote the last 4 lines.
I semi assume it's running out of memory, but don't know how to tell if that's really what is happening.
Any troubleshooting tips would be appreciated.