Last active
August 28, 2020 01:29
-
-
Save Spartan-196/ccd24578de26e144cf9e18b0bc2deabc to your computer and use it in GitHub Desktop.
RSAT 1809 and above Managed environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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