Install-RSAT.ps1

<#PSScriptInfo
 
.VERSION 1.0.1
 
.GUID 78fe3fa8-add6-47e8-8c0c-06baf75ea954
 
.AUTHOR Mosaicmk Software LLC
 
.COMPANYNAME Mosaicmk Software LLC
 
.COPYRIGHT (c) 2018 MosaicMK Software LLC. All rights reserved.
 
.TAGS Windows
 
.LICENSEURI https://opensource.org/licenses/MS-PL
 
.PROJECTURI https://www.mosaicmk.com
 
.ICONURI https://3.bp.blogspot.com/-5AH8bMtdvcU/XBpsEqKMoFI/AAAAAAAABIw/cRbUnQwTwdIpZapoCD4ifYatBmy717zSgCLcBGAs/s1600/logo-transparent_NoWords.png.ico
 
.EXTERNALMODULEDEPENDENCIES
 
.REQUIREDSCRIPTS
 
.EXTERNALSCRIPTDEPENDENCIES
 
.RELEASENOTES
#>


<#
.SYNOPSIS
Install RSAT Tools
.DESCRIPTION
The Script will install the selected RSAT tools for Windows 10 1809
.PARAMETER All
Installs all RSAT tools
.PARAMETER AD
Installs Active Directory
.PARAMETER DNS
Installs DNS
.PARAMETER GroupPolicy
Installs Group Policy
.PARAMETER WSUS
Installs WSUS
.PARAMETER ServerManager
Installs Server Manger
.PARAMETER Source
Specify offline files to install the tools
.PARAMETER GetInstalledTools
Gets the tools that are already installed
.PARAMETER GetNonInstalledTools
Gets the tools that are not installed
.NOTES
Contact: Contact@mosaicmk.com
Facebook: MosaicMK Software LLC
Version 1.0.1
.LINK
http://www.mosacimk.com
#>



PARAM(
    [switch]$All,
    [switch]$DHCP,
    [switch]$AD,
    [switch]$DNS,
    [switch]$GroupPolicy,
    [switch]$WSUS,
    [switch]$ServerManager,
    [string]$Source,
    [switch]$GetInstalledTools,
    [switch]$GetNonInstalledTools
)

IF ($All){
    $Tools = (Get-WindowsCapability -Online -Name "*RSAT*").name
    foreach ($Tool in $Tools){if ($Source){dism /Add-Capability /CapabilityName:$Tool /Online /Source:$Source} Else {dism /Add-Capability /CapabilityName:$Tool /Online}}
}

IF (!($All)){
    IF ($DHCP){
        $Tool = (Get-WindowsCapability -Online -Name "*Rsat.DHCP*").Name
        IF ($Source){dism /Add-Capability /CapabilityName:$Tool /Online /Source:$Source} else {dism /Add-Capability /CapabilityName:$Tool /Online}
    }

    IF ($DNS){
        $Tool = (Get-WindowsCapability -Online -Name "*Rsat.DNS*").Name
        IF ($Source){dism /Add-Capability /CapabilityName:$Tool /Online /Source:$Source} else {dism /Add-Capability /CapabilityName:$Tool /Online}
    }

    IF ($AD){
        $Tool = (Get-WindowsCapability -Online -Name "*Rsat.ActiveDirectory*").Name
        IF ($Source){dism /Add-Capability /CapabilityName:$Tool /Online /Source:$Source} else {dism /Add-Capability /CapabilityName:$Tool /Online}
    }

    IF ($GroupPolicy){
        $Tool = (Get-WindowsCapability -Online -Name "*Rsat.GroupPolicy*").Name
        IF ($Source){dism /Add-Capability /CapabilityName:$Tool /Online /Source:$Source} else {dism /Add-Capability /CapabilityName:$Tool /Online}
    }

    IF ($WSUS){
        $Tool = (Get-WindowsCapability -Online -Name "*Rsat.WSUS*").Name
        IF ($Source){dism /Add-Capability /CapabilityName:$Tool /Online /Source:$Source} else {dism /Add-Capability /CapabilityName:$Tool /Online}
    }

    IF ($ServerManager){
        $Tool = (Get-WindowsCapability -Online -Name "*Rsat.ServerManager*").Name
        IF ($Source){dism /Add-Capability /CapabilityName:$Tool /Online /Source:$Source} else {dism /Add-Capability /CapabilityName:$Tool /Online}
    }
}

IF ($GetInstalledTools){Get-WindowsCapability -Online -Name "*RSAT*" | Where-Object -Property State -eq "Installed" | Format-Table -AutoSize -Wrap -Property Name, DisplayName, Description}

IF ($GetNonInstalledTools){Get-WindowsCapability -Online -Name "*RSAT*" | Where-Object -Property State -eq "NotPresent" | Format-Table -AutoSize -Wrap -Property Name, DisplayName, Description}