Just make sure that Param
should be in the first line of your PowerShell script.
Normally, the application gets this error when it tries to access a file that is being used or locked by some another process.
Recently I stuck in a situation where I wanted to export variable groups from my VSTS account but there was no such option to export variable group. That time I came to know that VSTS has also exposed its API. After that, I just wrote a PowerShell to download all variable groups into a JSON file by calling its API.
Recently I started working on PowerShell as I was working on C# for a long time. Initially, it took me a while to get familiar with the PowerShell syntaxes. That’s why I thought to put all my google searches over here in this single post. I hope this will help you during your transition period from C# to PowerShell.
Both commands are used to set environment variable value in windows through command-line.