Windows 10 Remote Server Administration Tools

So the shiny and new Windows 10 v1809 has RSAT available as features on demand you can install simply using Add-WindowsCapability.  Great!

Unfortunately for me somewhere along the line my Windows 10 system, which had the 1803 RSAT tools installed, obtained standard Windows updates and the RSAT options were removed from Windows Features menu.  I wasn’t able to adjust the install state of my admin tools when I really needed to add a few.  I could have probably found the MSI uninstall string and re-installed the tools cleanly but with all the references to Feature on Demand I wanted to try something off the beaten path.

The following will scrape Microsoft’s page detailing the features and attempt to install them.  Your mileage may vary on the effectiveness of this script but it enabled everything I needed considering I had no other way to enable them via Add-WindowsCapability nor Windows Feature menu:

$URL = ''
$content = (Invoke-WebRequest $URL -UseBasicParsing).rawcontent -split "`r`n" | ? {$_ -match '^\s+<p>'} | % {$_ -split "`n"}

$rsat = @()
$rsat += $content | % {if($_ -match '.*Capability name.*(Rsat.*[\d\.]+)'){$matches[1].trim()}}

$success = @()
$failed = @()
if($rsat.count -gt 0)
  $rsat = $rsat | sort
  $total = $rsat.count
  $count = 1
  Write-Host "Remote Server Administration Tools Discovered: $total" -f Green
  foreach($tool in $rsat)
    Write-Host "[$count/$total] Installing $tool"
    try {Add-WindowsCapability -Online -Name $tool -source 'c:\windows\winsxs' -ea stop;$success+=$tool} catch {Write-Host $_.exception.message -f red;$failed+=$tool}


"`nRSAT Successfull Installs:  $($success.count)"
"`nRSAT Failed Installs:  $($failed.count)"