Skip to content

Instantly share code, notes, and snippets.

@Spartan-196
Last active August 28, 2020 01:29
Show Gist options
  • Save Spartan-196/ccd24578de26e144cf9e18b0bc2deabc to your computer and use it in GitHub Desktop.
Save Spartan-196/ccd24578de26e144cf9e18b0bc2deabc to your computer and use it in GitHub Desktop.
RSAT 1809 and above Managed environment
# RSAT 1809 in Managed WSUS environment
# Set variables
$wsusSetting = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\"
$name = "UseWUServer"
$value = "0"
$service = "wuauserv"
If (Test-Path $wsusSetting$name) {
# Get Current WSUS Settings
$currentReg = Get-ItemPropertyValue -Name $name -Path $wsusSetting -ErrorAction SilentlyContinue
# Set reg value and restart service
Set-ItemProperty -Path $wsusSetting -Name $name -Value $value -Force | Out-Null
Restart-Service $service -Force
$wsusreset=$true
}
# Install RSAT
Get-WindowsCapability -Online | ? Name -like 'RSAT*' | where { $_.State -eq 'NotPresent' } | foreach { Add-WindowsCapability -Online -Name $_.Name }
# Reset reg value and restart service
If ($wsusreset){
Set-ItemProperty -Path $wsusSetting -Name $name -Value $currentReg -Force | Out-Null
Restart-Service $service -Force
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment