Install RSAT from PowerShell

This script will detect if RSAT is installed, and if it’s not, then install. At the end it will return as $true or $false.

# Diagnostic Script Testing
#Get-WindowsCapability -Name RSAT* -Online | Where-Object {$_.State -eq "NotPresent"}

# Install Method
Get-WindowsCapability -Name RSAT* -Online | Where-Object {$_.State -eq "NotPresent"} | Add-WindowsCapability -Online

# Cleanup Script
Get-Variable status,rsatInstalled,rsatTool -ErrorAction Ignore | Remove-Variable -Scope Global -ErrorAction Ignore

# Detection Method
[array]$rsatInstalled = @(Get-WindowsCapability -Name RSAT* -Online | Select-Object -Property Name, State)
ForEach ($rsatTool in $rsatInstalled) {if ($rsatTool.State -eq "NotPresent") {$status += 1}}

# Return Script to Check Install Status
if (($status -eq $null) -or $status -ne 0) {Return $true} else {Return $false}

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.