I have an Azure DevOps build pipeline that has two separate PowerShell scripts. In the first script, I am getting a value from an XML file and setting that value in an environme
To set environmental variables you need to set it using
$env:departmentId = $myXml.Department.Id
When using variables within strings you still need the $ sign in front of variables. As in
Write-Host "Using Department: $($env:DepartmentId)"
The reason environmental variables look different for get-childItem is that you are actually listing a psprovider, not the accessing the variable.
Get-ChildItem Env:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-6