From ad84197031cc65727f5cca0ee0d03742a9188f9c Mon Sep 17 00:00:00 2001 From: Jeremy Camplin Date: Wed, 28 May 2025 09:02:32 +0800 Subject: [PATCH] Updated check .net framework for Windows 11 --- step-templates/windows-check-net-framework-version.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/step-templates/windows-check-net-framework-version.json b/step-templates/windows-check-net-framework-version.json index 80f6afba2..811920994 100644 --- a/step-templates/windows-check-net-framework-version.json +++ b/step-templates/windows-check-net-framework-version.json @@ -3,12 +3,12 @@ "Name": ".NET - Check .NET Framework Version", "Description": "Check if given .NET framework version (or greater) is installed.", "ActionType": "Octopus.Script", - "Version": 8, + "Version": 9, "CommunityActionTemplateId": "CommunityActionTemplates-561", "Properties": { "Octopus.Action.Script.Syntax": "PowerShell", "Octopus.Action.Script.ScriptSource": "Inline", - "Octopus.Action.Script.ScriptBody": "# This script is based on MSDN: https://msdn.microsoft.com/en-us/library/hh925568\n\n$releaseVersionMapping = @{\n 378389 = '4.5' # 4.5\n 378675 = '4.5.1' # 4.5.1 installed with Windows 8.1\n 378758 = '4.5.1' # 4.5.1 installed on Windows 8, Windows 7 SP1, or Windows Vista SP2\n 379893 = '4.5.2' # 4.5.2\n 393295 = '4.6' # 4.6 installed with Windows 10\n 393297 = '4.6' # 4.6 installed on all other Windows OS versions\n 394254 = '4.6.1' # 4.6.1 installed on Windows 10\n 394271 = '4.6.1' # 4.6.1 installed on all other Windows OS versions\n 394802 = '4.6.2' # 4.6.2 installed on Windows 10\n 394806 = '4.6.2' # 4.6.2 installed on all other Windows OS versions\n 460798 = '4.7' # 4.7 installed on Windows 10\n 460805 = '4.7' # 4.7 installed on all other Windows OS versions\n 461308 = '4.7.1' # 4.7.1 installed on Windows 10\n 461310 = '4.7.1' # 4.7.1 installed on all other Windows OS versions\n 461808 = '4.7.2' # 4.7.2 installed on Windows 10\n 461814 = '4.7.2' # 4.7.2 installed on all other Windows OS versions\n 528040 = '4.8' #4.8 installed on Windows 10\n 528049 = '4.8' #4.8 installed on all other Windows OS versions1\n 528372 = '4.8' # 4.8 Windows 10 May 2020 Update\n}\n\nfunction Get-DotNetFrameworkVersions() {\n $dotNetVersions = @()\n if ($baseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', '')) {\n # To find .NET Framework versions (.NET Framework 1-4)$dotNetVersions\n if ($ndpKey = $baseKey.OpenSubKey('SOFTWARE\\Microsoft\\NET Framework Setup\\NDP')) {\n foreach ($versionKeyName in $ndpKey.GetSubKeyNames()) {\n if ($versionKeyName -match 'v[2|3]') {\n $versionKey = $ndpKey.OpenSubKey($versionKeyName)\n if ($versionKey.GetValue('Version', '') -ne '') {\n $version = [version] ($versionKey.GetValue('Version'))\n $dotNetVersions += \"$($version.Major).$($version.Minor)\"\n }\n }\n }\n \n # for .NET 4.0\n if ($ndp40Key = $ndpKey.OpenSubKey(\"v4.0\")) {\n foreach ($subKeyName in $ndp40Key.GetSubKeyNames()) {\n $versionKey = $ndp40Key.OpenSubKey($subKeyName)\n $version = [version]($versionKey.GetValue('Version', ''))\n $dotNetVersions += \"$($version.Major).$($version.Minor)\"\n }\n }\n }\n\n # To find .NET Framework versions (.NET Framework 4.5 and later)\n if ($ndp4Key = $baseKey.OpenSubKey('SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full')) {\n $releaseKey = $ndp4Key.GetValue('Release')\n $dotNetVersions += $releaseVersionMapping[$releaseKey]\n }\n }\n return $dotNetVersions\n}\n\n$targetVersion = $OctopusParameters['TargetVersion'].Trim()\n$exact = [boolean]::Parse($OctopusParameters['Exact'])\n\n$matchedVersions = Get-DotNetFrameworkVersions | Where-Object { if ($exact) { $_ -eq $targetVersion } else { $_ -ge $targetVersion } }\nif (!$matchedVersions) { \n throw \"Can't find .NET $targetVersion installed in the machine.\"\n}\n$matchedVersions | foreach { Write-Host \"Found .NET $_ installed in the machine.\" }", + "Octopus.Action.Script.ScriptBody": "# This script is based on MSDN: https://msdn.microsoft.com/en-us/library/hh925568\n\n$releaseVersionMapping = @{\n 378389 = '4.5' # 4.5\n 378675 = '4.5.1' # 4.5.1 installed with Windows 8.1\n 378758 = '4.5.1' # 4.5.1 installed on Windows 8, Windows 7 SP1, or Windows Vista SP2\n 379893 = '4.5.2' # 4.5.2\n 393295 = '4.6' # 4.6 installed with Windows 10\n 393297 = '4.6' # 4.6 installed on all other Windows OS versions\n 394254 = '4.6.1' # 4.6.1 installed on Windows 10\n 394271 = '4.6.1' # 4.6.1 installed on all other Windows OS versions\n 394802 = '4.6.2' # 4.6.2 installed on Windows 10\n 394806 = '4.6.2' # 4.6.2 installed on all other Windows OS versions\n 460798 = '4.7' # 4.7 installed on Windows 10\n 460805 = '4.7' # 4.7 installed on all other Windows OS versions\n 461308 = '4.7.1' # 4.7.1 installed on Windows 10\n 461310 = '4.7.1' # 4.7.1 installed on all other Windows OS versions\n 461808 = '4.7.2' # 4.7.2 installed on Windows 10\n 461814 = '4.7.2' # 4.7.2 installed on all other Windows OS versions\n 528040 = '4.8' # 4.8 installed on Windows 10\n 528049 = '4.8' # 4.8 installed on all other Windows OS versions1\n 528372 = '4.8' # 4.8 Windows 10 May 2020 Update\n 528449 = '4.8' # 4.8 Windows 11 and Windows Server 2022\n 533320 = '4.8.1' # 4.8 Windows 11 September 2022 Release and Windows 11 October 2023 Release\n 533325 = '4.8.1' # 4.8 all other OS versions\n}\n\nfunction Get-DotNetFrameworkVersions() {\n $dotNetVersions = @()\n if ($baseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', '')) {\n # To find .NET Framework versions (.NET Framework 1-4)$dotNetVersions\n if ($ndpKey = $baseKey.OpenSubKey('SOFTWARE\\Microsoft\\NET Framework Setup\\NDP')) {\n foreach ($versionKeyName in $ndpKey.GetSubKeyNames()) {\n if ($versionKeyName -match 'v[2|3]') {\n $versionKey = $ndpKey.OpenSubKey($versionKeyName)\n if ($versionKey.GetValue('Version', '') -ne '') {\n $version = [version] ($versionKey.GetValue('Version'))\n $dotNetVersions += \"$($version.Major).$($version.Minor)\"\n }\n }\n }\n \n # for .NET 4.0\n if ($ndp40Key = $ndpKey.OpenSubKey(\"v4.0\")) {\n foreach ($subKeyName in $ndp40Key.GetSubKeyNames()) {\n $versionKey = $ndp40Key.OpenSubKey($subKeyName)\n $version = [version]($versionKey.GetValue('Version', ''))\n $dotNetVersions += \"$($version.Major).$($version.Minor)\"\n }\n }\n }\n\n # To find .NET Framework versions (.NET Framework 4.5 and later)\n if ($ndp4Key = $baseKey.OpenSubKey('SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full')) {\n $releaseKey = $ndp4Key.GetValue('Release')\n $dotNetVersions += $releaseVersionMapping[$releaseKey]\n }\n }\n return $dotNetVersions\n}\n\n$targetVersion = $OctopusParameters['TargetVersion'].Trim()\n$exact = [boolean]::Parse($OctopusParameters['Exact'])\n\n$matchedVersions = Get-DotNetFrameworkVersions | Where-Object { if ($exact) { $_ -eq $targetVersion } else { $_ -ge $targetVersion } }\nif (!$matchedVersions) { \n throw \"Can't find .NET $targetVersion installed in the machine.\"\n}\n$matchedVersions | foreach { Write-Host \"Found .NET $_ installed in the machine.\" }", "Octopus.Action.RunOnServer": "false" }, "Parameters": [ @@ -40,6 +40,6 @@ "OctopusVersion": "2018.4.1", "Type": "ActionTemplate" }, - "LastModifiedBy": "hullscotty1986", + "LastModifiedBy": "JeremyCamplin", "Category": "aspnet" -} \ No newline at end of file +}