Share via


Installing Remote Server Admin Tools (RSAT) via Powershell

I reload my boxes frequently, also I have a few installations that are enrolled in Windows Insider, which installs new builds frequently. The insider build update cycle will reset existing updates including Remote Server Tools (Active Directory Powershell, Active Directory Users and Computer, etc) .. Drew is not one to download and install things over and over again.. so so created the following  PS code.

Following PS code will install server admin tools on 'Windows Server*' and Remote Server Administration Tools (RSAT) Windows 10 (x86/x64).  

CODE:

  1 2 3 4 5 6 7 8 91011121314151617181920212223242526272829303132
 #Requires -RunAsAdministrator$web = Invoke-WebRequest https://www.microsoft.com/en-us/download/confirmation.aspx?id=45520$MachineOS= (Get-WmiObject Win32_OperatingSystem).Name#Check for Windows Server 2012 R2IF($MachineOS -like "*Microsoft Windows Server*") {        Add-WindowsFeature RSAT-AD-PowerShell    Break}        IF ($ENV:PROCESSOR_ARCHITECTURE -eq "AMD64"){            Write-host "x64 Detected" -foregroundcolor yellow            $Link=(($web.AllElements |where class -eq "multifile-failover-url").innerhtml[0].split(" ")|select-string href).tostring().replace("href=","").trim('"')            }ELSE{            Write-host "x86 Detected" -forgroundcolor yellow            $Link=(($web.AllElements |where class -eq "multifile-failover-url").innerhtml[1].split(" ")|select-string href).tostring().replace("href=","").trim('"')            }$DLPath= ($ENV:USERPROFILE) + "\Downloads\" + ($link.split("/")[8])Write-Host "Downloading RSAT MSU file" -foregroundcolor yellowStart-BitsTransfer -Source $Link -Destination $DLPath$Authenticatefile=Get-AuthenticodeSignature $DLPath$WusaArguments = $DLPath + " /quiet"if($Authenticatefile.status -ne "valid") {write-host "Can't confirm download, exiting";break}Write-host "Installing RSAT for Windows 10 - please wait" -foregroundcolor yellowStart-Process -FilePath "C:\Windows\System32\wusa.exe" -ArgumentList $WusaArguments -Wait

#Update,  W10 build 17682 includes RSAT on demand

#Example, List all RSAT

Get-WindowsCapability -Online | ? Name -like 'RSAT.*'

#Example, Install  Directory Services

Get-WindowsCapability -Online | ? Name -like Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0 |Add-WindowsCapability -Online

#Example, install complete RSAT

Get-WindowsCapability -Online | ? Name -like 'RSAT.*' | Add-WindowsCapability -Online

Comments

  • Anonymous
    June 01, 2017
    For anyone looking at this script, it is pointing to an older MSU and the certificate will date-check fail. You can try to update this script with valid installers by getting URL from latest from here. https://www.microsoft.com/en-us/download/details.aspx?id=45520
    • Anonymous
      June 01, 2017
      Hi Robert, thanks. I updated the request, it now scrapes the uri from the links, tested and confirmed works fine now.
  • Anonymous
    June 01, 2017
    I don't think the link I provided will provide direct links to the MSU downloads. I'm unable to determine easily what those would be without some wireshark or debugging in the browser.So, I'd suggest downloading each of these manually and placing on a locally accessible server.
  • Anonymous
    November 08, 2017
    The comment has been removed