Powershell psm1 file running slowly when task scheduler calls it.

So I have a psm1 file that works. Finishes in less than a minute.(some file deleting, copying, and wmi-object calls to get some report info from servers)

I can run it all day from a powershell window, from a .bat file referencing the psm1, no problem. But when I run it as a task in Windows 2012 task scheduler, it takes about 5 minutes to reach the first line(which deletes one file). I can’t say if it ever finishes because I stopped waiting after an hour. It does successfully execute some lines, but I can’t tell if it’s either stuck or just taking a long time to do the rest.

Does anyone know why this would be happening? It’s one of those issues that is borderline unpowershell-related because the code works, but I just can’t seem to figure it out yet.

submitted by /u/GardenVariety_Wraith
[link] [comments]

Leave a Reply