Preview:
$role = "DHCP"
$feature = "RSAT-DHCP"
$computers = "Server1", "Server2", "Server3"
$action = Read-Host "Enter 'install', 'uninstall', or 'check' for the role/feature"

foreach ($computer in $computers) {
    Invoke-Command -ComputerName $computer -ScriptBlock {
        if ($action -eq "install") {
            Install-WindowsFeature -Name $role, $feature -IncludeAllSubFeature -IncludeManagementTools
        } elseif ($action -eq "uninstall") {
            Uninstall-WindowsFeature -Name $role, $feature -Remove
        } elseif ($action -eq "check") {
            Get-WindowsFeature -Name $role, $feature | Format-Table -Property Name, DisplayName, Installed
        } else {
            Write-Host "Invalid action specified"
        }
    }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter