Unable to run PnP PowerShell from a Task Scheduler

Valued 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?

1 Reply
Set $env:PSModulePath to include your pnp power shell folder.