Skip to content

Instantly share code, notes, and snippets.

@d4rkeagle65
Created March 19, 2020 21:45
Show Gist options
  • Save d4rkeagle65/4cd34d7d3ebd931acdc931d5c844930b to your computer and use it in GitHub Desktop.
Save d4rkeagle65/4cd34d7d3ebd931acdc931d5c844930b to your computer and use it in GitHub Desktop.
Powershell script to setup a quick standalone RDS server.
# Install Powershell Modules
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-WindowsFeature RSAT-AD-PowerShell
# Install RDS Server Features
Add-WindowsFeature –Name RDS-Gateway –IncludeAllSubFeature
Add-WindowsFeature –Name RDS-Connection-Broker –IncludeAllSubFeature
Get-WindowsFeature | ? { $_.Name -match "RDS-Licensing|RDS-RD-Server" } | Install-WindowsFeature –IncludeAllSubFeature
# Set Firewall and Service Settings for RD
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Value 0
New-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" -Name Shadow -Value 2 -PropertyType "DWORD"
Add-FirewallRuleNetSh -name "TerminalServer: RDP TCP-3389" -dir "in" -action "allow" -protocol "TCP" -localport "3389"
Add-FirewallRuleNetSh -name "TerminalServer: RDP TCP-3389" -dir "in" -action "allow" -protocol "UDP" -localport "3389"
#Reboot
# Import Powershell Modules
Import-Module ActiveDirectory
Import-Module RemoteDesktop
# Sets Variables/Server Target Names
$serverName = ""
$conBroker = $serverName
$waSvr = $serverName
$sHost = $serverName
$licServer = $serverName
$licMode = "PerUser"
$alternateServers = @()
$collectionName = ($env:computerName + "." + (Get-ADDomain).DNSRoot)
# Creates the New RD Session Deployment
New-RDSessionDeployment -ConnectionBroker $conBroker -WebAccessServer $waSvr -SessionHost $sHost
# Adds Any Additional New Servers to the Deployment
$alternateServers | Foreach-Object { Add-RDServer -Server $_ -Role RDS-RD-SERVER -ConnectionBroker $conBroker }
# Creates the New Collection
New-RDSessionCollection -CollectionName $collectionName -SessionHost $sHost -CollectionDescription ("RDS Collection for " + $collectionName) -ConnectionBroker $conBroker
# Adds a Licensing Server.
Set-RDLicenseConfiguration -LicenseServer $licServer -Mode $licMode -ConnectionBroker $conBroker -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment