0

I am new to DevOps and trying to access the secure file via PowerShell script. Here is the scenario:

Agent I am using is ubuntu 18.04 I have uploaded my certificate as secure file and able to download when I am executing the pipeline. I have verified it by seeing the $(Agent.TempDirectory) content where certificate (.cer) is present.

Then I am running a PowerShell script which has below line of code:

$Certificate = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new('$(Agent.TempDirectory)/mycert.cer')

But this line always gives me the below error:

enter image description here

What is wrong here.

1 Answer 1

2

The macro syntax $() will be expanded only in the template. If your script is stored in the file, you need to use environment variable: $env:AGENT_TEMPDIRECTORY

$Certificate = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new("$env:AGENT_TEMPDIRECTORY/mycert.cer")
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.