3 Replies Latest reply on Jan 11, 2016 7:28 AM by Zsoldier

    Import-Module via scheduled task results in different $env:modulepath

    Zsoldier Expert
    vExpert

      Just upgraded to PowerCLI 6.0 R3

      Has anyone run into this?  I was updating my scheduled task scripts to start importing the module rather than adding the snapins, but for some reason when task scheduler runs the scripts, it basically errors out w/ unable to find valid module.

       

      When the task scheduler job as the service account runs it, $env:modulepath looks like this:

      C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;D:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\;C:\Dell_PSCmdlets;C:\Program Files (x86)\AWS Tools\PowerShell\;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement


      When I run it interactively as the service account, I see that the module is listed properly in the modulepath environment variable.

      C:\Users\svcLDAPVMware\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;D:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\;C:\Dell_PSCmdlets;C:\Program Files (x86)\AWS Tools\PowerShell\;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement;D:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Modules