Issue
Using Jenkins 2.46.2 on Windows Server 2012 R2.
I have pipeline script that runs:
bat 'env'
I'm interested in environment variable: PSModulePath
PSModulePath=C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
in my console output. However, if I run this logged on as the Jenkins account on the Jenkins server, I get a different result:
PSModulePath=C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\;C:\Program File
s (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules\;C:\Program Files\Wind
owsPowerShell\Modules
Why is that? I can't load some modules in a Jenkins job because they can't be found.
Solution
I worked around this by explicitly adding the path as an environment variable to Jenkins, but I don't know why I had to do that. Anyway it works now.
Answered By - Mark Allison
Answer Checked By - Gilberto Lyons (JavaFixing Admin)