Forum Discussion
GouravIN
Jul 14, 2022Brass Contributor
Partial script not running while deployment
Hi All, I am deploying a windows VM in Azure using terraform and want to install some software while deployment so I thought about PS script extension. Things are working fine for me however ...
Kidd_Ip
Nov 17, 2025MVP
Seems environment variable not persisting because the Custom Script Extension runs in a transient process context. When you use Set-Item Env:\Path, it only updates the environment for that running PowerShell session. Once the extension finish, the VM boots into a fresh session and the change is gone. To make PATH (or any env var) stick across reboots and be visible to all processes, you may require to write it to the machine-level environment registry or use [System.Environment]::SetEnvironmentVariable() with the right scope.