diff --git a/images/win/scripts/Installers/Initialize-VM.ps1 b/images/win/scripts/Installers/Initialize-VM.ps1 index 0277287276c0..26ce2a4ec463 100644 --- a/images/win/scripts/Installers/Initialize-VM.ps1 +++ b/images/win/scripts/Installers/Initialize-VM.ps1 @@ -33,6 +33,10 @@ function Disable-UserAccessControl { # Enable $ErrorActionPreference='Stop' for AllUsersAllHosts Add-Content -Path $profile.AllUsersAllHosts -Value '$ErrorActionPreference="Stop"' +# Set static env vars +setx ImageVersion $env:IMAGE_VERSION /m +setx ImageOS $env:IMAGE_OS /m + # Set TLS1.2 [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12" diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index 9bdd4a704229..3203c5bf92ce 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -17,7 +17,7 @@ $markdown += New-MDHeader "$OSName" -Level 1 $OSVersion = Get-OSVersion $markdown += New-MDList -Style Unordered -Lines @( "$OSVersion" - "Image Version: $env:ImageVersion" + "Image Version: $env:IMAGE_VERSION" ) if (Test-IsWin19) diff --git a/images/win/windows2016.json b/images/win/windows2016.json index 9383a2a17a59..f7762385bf2c 100644 --- a/images/win/windows2016.json +++ b/images/win/windows2016.json @@ -112,7 +112,8 @@ { "type": "powershell", "environment_vars": [ - "ImageVersion={{user `image_version`}}", + "IMAGE_VERSION={{user `image_version`}}", + "IMAGE_OS={{user `image_os`}}", "TOOLSET_JSON_PATH={{user `toolset_json_path`}}", "PSMODULES_ROOT_FOLDER={{user `psmodules_root_folder`}}" ], @@ -134,13 +135,6 @@ "type": "windows-restart", "restart_timeout": "30m" }, - { - "type": "powershell", - "inline": [ - "setx ImageVersion {{user `image_version` }} /m", - "setx ImageOS {{user `image_os` }} /m" - ] - }, { "type": "powershell", "environment_vars": [ @@ -357,6 +351,7 @@ "pwsh -File '{{user `image_folder`}}\\SoftwareReport\\SoftwareReport.Generator.ps1'" ], "environment_vars": [ + "IMAGE_VERSION={{user `image_version`}}", "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" ] }, diff --git a/images/win/windows2019.json b/images/win/windows2019.json index 39b58c003a66..24e1ec6406a6 100644 --- a/images/win/windows2019.json +++ b/images/win/windows2019.json @@ -112,7 +112,8 @@ { "type": "powershell", "environment_vars": [ - "ImageVersion={{user `image_version`}}", + "IMAGE_VERSION={{user `image_version`}}", + "IMAGE_OS={{user `image_os`}}", "TOOLSET_JSON_PATH={{user `toolset_json_path`}}", "PSMODULES_ROOT_FOLDER={{user `psmodules_root_folder`}}" ], @@ -138,13 +139,6 @@ "{{ template_dir }}/scripts/Installers/Install-ContainersFeature.ps1" ] }, - { - "type": "powershell", - "inline": [ - "setx ImageVersion {{user `image_version` }} /m", - "setx ImageOS {{user `image_os` }} /m" - ] - }, { "type": "windows-restart", "restart_timeout": "10m" @@ -350,6 +344,7 @@ "pwsh -File '{{user `image_folder`}}\\SoftwareReport\\SoftwareReport.Generator.ps1'" ], "environment_vars": [ + "IMAGE_VERSION={{user `image_version`}}", "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" ] },