Drew Robinson's Blog

Azure, Powershell and Security things

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
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#Requires -RunAsAdministrator

<#  
.SYNOPSIS  
    - downloads and installs Windows Remote Server Admin tools (RSAT), Active Directory Powershell, Active Directory Users and Computer, DHCP, DNS, etc
    
.DESCRIPTION  
    
.NOTES  
    File Name       : rsat.ps1
      : drew.robinson@microsoft.com
#>    
    



# Check for Server (RSAT builtin), if server install RSAT and Break out of script
    $MachineOS= (Get-WmiObject Win32_OperatingSystem).Name
    IF($MachineOS -like "*Microsoft Windows Server*") {
    Add-WindowsFeature RSAT -IncludeAllSubFeature
    Break}


# Check for architecture and create var for assoicated link
    IF ($ENV:PROCESSOR_ARCHITECTURE -eq "AMD64"){
    Write-host "x64 Detected" -foregroundcolor yellow
    $Link="https://download.microsoft.com/download/1/D/8/1D8B5022-5477-4B9A-8104-6A71FF9D98AB/WindowsTH-RSAT_TP5-x64.msu"
    }ELSE{
    Write-host "x86 Detected" -forgroundcolor yellow
    $Link="https://download.microsoft.com/download/1/D/8/1D8B5022-5477-4B9A-8104-6A71FF9D98AB/WindowsTH-RSAT_WS2016-x86.msu"
        }

# Set download path to userprofilepath(~)\download, download msu file
    $DLPath= ($ENV:USERPROFILE) + "\Downloads\" + ($link.split("/")[8])
    Write-Host "Downloading RSAT MSU file" -foregroundcolor yellow
    Start-BitsTransfer -Source $Link -Destination $DLPath

# Check signature on file, break out of script if not valid
    $Authenticatefile=Get-AuthenticodeSignature $DLPath
    if($Authenticatefile.status -ne "valid") {write-host "Can’t confirm download, exiting";break}

# install RSAT
    $WusaArguments = $DLPath + " /quiet"
    Write-host "Installing RSAT for Windows 10 – please wait" -foregroundcolor yellow
    Start-Process -FilePath "C:\Windows\System32\wusa.exe" -ArgumentList $WusaArguments -Wait