Resolve Environmental Variable Not Expanding in PowerShell Script on Windows - DevPops-Inc/windows GitHub Wiki

• The following resolution is for if an environment variable won’t expand in a PowerShell script.
image

• Open the PowerShell script in your desired code editor then go to before you return the variable that contains the environment variable and press the Enter key to create a new space.
image

• Type $< variable > = $ExecutionContext.InvokeCommand.ExpandString($< variable >) to expand the environment variable and save the value in a variable.
image

• Run the PowerShell script again.
image

• The environment variable will expand this time around.
image

⚠️ **GitHub.com Fallback** ⚠️