This PowerShell script will install all RSAT packages excluding ones that are already present. It has been tested on Windows 10 but may also work on other Windows versions.
$Install = Get-WindowsCapability -Online | Where-Object {$_.Name -like "Rsat*" -AND $_.State -eq "NotPresent"}
$Install | ForEach-Object {
$RSATName = $_.Name
Add-WindowsCapability -Online -Name $RsatName
}