0

In Azure DevOps, I have an Azure Powershell task to create some resources using ps1 script in repo. This script working fine.

Now I need to split the script and variables into different files. I created files SB-Config.ps1 for variables and ServiceBus.ps1 with main script. Moved all vars into SB-Config.ps1 . Both files are in the same folder and in ServiceBus.ps1 I added:

. .\SB-Config.ps1

But Azure Devops fails with error:

enter image description here

What I'm doing wrong and how to get variables from SB-Config.ps1 script, when running ServiceBus.ps1 file?

1
  • 1
    Use this in your first script: Set-Location $env:System_DefaultWorkingDirectory\subfolders I have posted the answer. Commented Mar 22, 2022 at 7:22

1 Answer 1

1

I am able to reproduce your situation on my side.

Same issue as yours.

You can run this command to output the location of current work space:

Get-Location

I notice the powershell script file on your side is in the sub folder of Default working directory.

So do you set the work space in the powershell script file you are running first?

Set-Location $env:System_DefaultWorkingDirectory\subfolders

In your situation, I think the issue comes from the current work space is System_DefaultWorkingDirectory , the error output means the script can't get the file you want. This issue only occurs when you select 'file path' to run.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Bowman! Yes, you're right, thanks! This helped me a lot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.