Installieren der Remote Server Tools in Windows 10

<#
.SYNOPSIS
Installs the Remote Server Administration Tools (RSAT) and its requirements.

.DESCRIPTION
This function installs the RSAT tool and its requirements on the local machine. The RSAT tool allows administrators to remotely manage Windows servers from a Windows client computer.

.NOTES
- This function requires administrative privileges to install the RSAT tool.
- The RSAT tool and its requirements may vary depending on the Windows version.

.EXAMPLE
Install-RSAT
Installs the RSAT tool and its requirements on the local machine.
#>
function Install-RSAT
{
	# Check if the user has administrative privileges
	if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
	{
		Write-Output "This function requires administrative privileges."
		exit 1
	}
	
	# Check the Windows version
	$osVersion = (Get-WmiObject -Class Win32_OperatingSystem).Caption
	$isWindows10 = $osVersion -like "*Windows 10*"
	
	# Install the RSAT tool and its requirements
	if ($isWindows10)
	{
		# RSAT for Windows 10
		Write-Output "Installing RSAT for Windows 10..."
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.BitLocker.Recovery.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.CertificateServices.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.DHCP.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.Dns.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.FailoverCluster.Management.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.FileServices.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.IPAM.Client.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.LLDP.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.NetworkController.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.NetworkLoadBalancing.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.RemoteAccess.Management.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.RemoteDesktop.Services.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.ServerManager.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.Shielded.VM.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.StorageMigrationService.Management.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.StorageReplica.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.SystemInsights.Management.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.VolumeActivation.Tools~~~~0.0.1.0" -NoRestart
		Enable-WindowsOptionalFeature -Online -FeatureName "Rsat.WSUS.Tools~~~~0.0.1.0" -NoRestart
		Write-Output "RSAT for Windows 10 has been installed."
	}
	else
	{
		# RSAT for other Windows versions
		Write-Output "Installing RSAT for other Windows versions..."
		$rsatInstallerPath = "https://download.microsoft.com/download/1/1/7/117FB25C-8F8C-42E3-9F0E-7A5BFB5C0F9F/WindowsTH-RSAT_WS2016-x64.msu"
		$rsatInstallerFilePath = "$env:TEMP\WindowsTH-RSAT_WS2016-x64.msu"
		
		# Download the RSAT installer
		Write-Output "Downloading RSAT installer..."
		Invoke-WebRequest -Uri $rsatInstallerPath -OutFile $rsatInstallerFilePath
		
		# Install RSAT
		Write-Output "Installing RSAT..."
		Start-Process -FilePath $rsatInstallerFilePath -ArgumentList "/quiet" -Wait
		
		# Clean up the RSAT installer file
		Write-Output "Cleaning up..."
		Remove-Item -Path $rsatInstallerFilePath
		
		Write-Output "RSAT has been installed."
	}
}

# Usage example for the Install-RSAT function
Install-RSAT