I have tried to execute below commands from Jenkins consecutively:
Import-Module -Name "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"
cd IPL:
But it seems like Jenkins is releasing the session after executing each command. Hence we have tried to keep a delay between two command, but no luck:
Import-Module -Name "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"
Start-Sleep -s 5
cd IPL:
While executing script, Jenkins is taking each command from its workspace directory D:\jenkins\workspace\<JobName>
. I was looking to modify the configuration in such a way, where Jenkins will execute entire script (with all commands within) from the same drive where script is located. Not from the Jenkins workspace.
But not such materials available in google. I have looked into the Jenkins Workspace modification area (Jenkins->Manage Jenkins->Configure System and click on the Advanced)
Jenkins Workspace Modification
But it will not help as, it will only change the workspace path and whenever we will execute the script. Again it will take individual command inside workspace and will execute them over there instead of directory where script is located.
Is there any way can we execute all the command (from a single powershell script) without terminate the session for each command? So that the powershell script script can be executed for it own directory only?