i have variable in variable group and I try to use hem in Invoke-Command -ScriptBlock
and is not found the variable , not succes to reach to variables in variable group
the script run in powershell , in release
Invoke-Command -ComputerName X -ScriptBlock {
Write-Host $env:Mypod
}
I read about argument list , but I dont know how to do it .
CodePudding user response:
As suggested by Dilly B:
You can pass the argument to Invoke-Command
to reach to variables in variable group:
$var1 = $env:Mypod
Invoke-Command -ComputerName X -ScriptBlock { Write-Host $args[0] } -ArgumentList $var1
You can refer to Use a variable group's secret and nonsecret variables in an Azure Pipeline and Azure DevOps: how to manage CI/CD variable groups using PowerShell