Unable to run PnP PowerShell from a Task Scheduler

Silver Contributor

I am trying to schedule a PnP PowerShell script from a Task Scheduler on a server.  I have installed the PnP module on the server.

 

If I manually run the script in PowerShell or in the ISE, the script run fines, but when I try to run it from the Task Scheduler, it is "unaware" of the PnP commands.

 

I've tried adding an "Import-Module SharePointPnPPowerShellOnline" to the script to no avail.

 

Any advice for solving this?

2 Replies
Set $env:PSModulePath to include your pnp power shell folder.

Can you please help me on how to set Set $env:PSModulePath on task scheduler ?