Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Evaluation Code Start
- #Evalaution Script - Determine if Target Release Version Registry keys exist and are set
- # Define Values in this section and ensure they match the values set in the remediation script
- #############################################
- $rValue = '1' #Enable Target Release Version 0 = Disabled, 1 = Enabled
- $rProductValue = 'Windows 10'
- $rInfoValue = '22H2' #Specify Windows 10 Target Release Version. Select the preferred version from https://docs.microsoft.com/en-us/windows/release-information/
- #############################################
- #Predefined variables
- $rPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate'
- $rProductName = 'ProductVersion'
- $rVersion = 'TargetReleaseVersion'
- $rVersionInfo = 'TargetReleaseVersionInfo'
- #Check if $rVersion registry value missing
- try{
- $cVersion = Get-ItemPropertyValue -Path $rPath -Name $rVersion -ErrorAction Stop
- $cProductInfo = Get-ItemPropertyValue -Path $rPath -Name $rProductName -ErrorAction Stop
- $cVersionInfo = Get-ItemPropertyValue -Path $rPath -Name $rVersionInfo -ErrorAction Stop
- }
- catch{
- Write-Error "Unable to read registry values"
- Exit -1
- }
- #Check if registry value data matches defined values
- if (($cVersion -eq $rValue) -and ($rInfoValue -eq $cVersionInfo) -and ($cProductInfo -eq $rProductValue)) {
- Exit 0
- } else { Exit -1 }
- #Remediation Code Start
- <#
- .SYNOPSIS
- Configure Windows 10 Target Release Version
- .DESCRIPTION
- Uses group policy registry keys to Enable and configure Target Release Version for Windows 10.
- Target Release Version
- Enable = 1 or Disable = 0
- Target Releaese Version Info
- Specify the preferred version of Windows 10. Enter version from https://docs.microsoft.com/en-us/windows/release-information/
- .NOTES
- Author: Automox
- Please note, these settings remain in the registry, and would require modification or removal to change or revert back to default.
- .PREREQUISITES
- Windows 10 1803 or higher
- Managable SKU (Pro, Education, Enterprise, Business)
- #>
- # Define Values in this section
- #############################################
- $rValue = '1' #Enable Target Release Version 0 = Disabled, 1 = Enabled
- $rInfoValue = '22H2' #Specify Windows 10 Target Release Version. Select the preferred version from https://docs.microsoft.com/en-us/windows/release-information/
- $rInfoProduct = 'Windows 10'
- #############################################
- $rPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate'
- $rKeyPath = 'HKLM:\Software\Policies\Microsoft\Windows'
- $rVersion = 'TargetReleaseVersion'
- $rVersionInfo = 'TargetReleaseVersionInfo'
- $rInfoProductName = 'ProductVersion'
- try {
- if(-not(Test-Path -path $rPath)){
- New-Item -Path $rPath -Force -ErrorAction Stop | Out-Null
- }
- Write-Output "SUCESS: Added Windows Product"
- New-ItemProperty -Path $rPath -Name $rInfoProductName -PropertyType String -Value $rInfoProduct -Force -ErrorAction Stop | Out-Null
- Write-Output "SUCCESS: Target Release Version keys set`t"
- New-ItemProperty -Path $rPath -Name $rVersion -PropertyType DWord -Value $rValue -Force -ErrorAction Stop | Out-Null
- Write-Output "$rpath exists`t"
- New-ItemProperty -Path $rPath -Name $rVersionInfo -PropertyType String -Value $rInfoValue -Force -ErrorAction Stop | Out-Null
- Write-Output "$rVersion = $rvalue and $rVersionInfo = $rInfoValue`t"
- Exit 0
- } catch { $Exception = $error[0].Exception.Message + "`nAt Line " + $error[0].InvocationInfo.ScriptLineNumber
- Write-Error $Exception
- Exit 90
- }
Advertisement
Add Comment
Please, Sign In to add comment