Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Loading Modules on Scheduled Task

$
0
0

Greetings,

I have a script whereby it is scheduled to run (by the windows task scheduler) weekly and requires several snap-pins and modules (Exchange, Active Dir, etc.) for queries and reporting.

What I noticed is that during development within a PS and the modules loaded, everything works fine. However, when the scheduled task runs, is seems to skip the loading process and runs the script before all the modules are ready. 

I tried two things:

1) Loading the modules at the beginning of the script:

Get-Module -ListAvailable | Import-Module

Get-PSSnapin -Registered | Add-PSSnapin -Passthru 

2) Adding the two lines in the powershell profile

Both efforts do not work. Feedback/suggestions are most appreciated.

Thank you for your timely response

David Paul

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles