-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCreateAppServer.ps1
More file actions
128 lines (115 loc) · 3.86 KB
/
Copy pathCreateAppServer.ps1
File metadata and controls
128 lines (115 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
configuration CreateAppServer
{
param
(
[Parameter(Mandatory)]
[String]$DnsServerAddress,
[Parameter(Mandatory)]
[String]$MachineName,
[Parameter(Mandatory)]
[String]$DomainName,
[Parameter(Mandatory)]
[PSCredential]$AdminCreds
)
Import-DscResource -Module xNetworking, xComputerManagement, xRemoteDesktopSessionHost
[PSCredential]$DomainCreds = New-Object System.Management.Automation.PSCredential("${DomainName}\$($AdminCreds.UserName)", $AdminCreds.Password)
[String]$localhost = $MachineName + "." + $DomainName
[String]$collectionName = 'mycollection'
[String]$collectionDescription = 'My first collection'
[String]$commandLineParameter = '/v:' + $DnsServerAddress
Node localhost
{
LocalConfigurationManager
{
ConfigurationMode = 'ApplyOnly'
RebootNodeIfNeeded = $true
}
xDnsServerAddress DnsServerAddress
{
Address = $DnsServerAddress
InterfaceAlias = 'Ethernet'
AddressFamily = 'IPv4'
}
xComputer JoinDomain
{
Name = $MachineName
DomainName = $DomainName
Credential = $DomainCreds
DependsOn = "[xDnsServerAddress]DnsServerAddress"
}
WindowsFeature Remote-Desktop-Services
{
Ensure = "Present"
Name = "Remote-Desktop-Services"
DependsOn = "[xComputer]JoinDomain"
}
WindowsFeature RDS-RD-Server
{
Ensure = "Present"
Name = "RDS-RD-Server"
DependsOn = "[xComputer]JoinDomain"
}
WindowsFeature RDS-Connection-Broker
{
Ensure = "Present"
Name = "RDS-Connection-Broker"
DependsOn = "[xComputer]JoinDomain"
}
WindowsFeature RDS-Licensing
{
Ensure = "Present"
Name = "RDS-Licensing"
DependsOn = "[xComputer]JoinDomain"
}
WindowsFeature RDS-Web-Access
{
Ensure = "Present"
Name = "RDS-Web-Access"
DependsOn = "[xComputer]JoinDomain"
}
xRDSessionDeployment Deployment
{
SessionHost = $localhost
ConnectionBroker = $localhost
WebAccessServer = $localhost
DependsOn = "[WindowsFeature]Remote-Desktop-Services", "[WindowsFeature]RDS-RD-Server"
}
xRDSessionCollection Collection
{
CollectionName = $collectionName
CollectionDescription = $collectionDescription
SessionHost = $localhost
ConnectionBroker = $localhost
DependsOn = "[xRDSessionDeployment]Deployment"
}
xRDSessionCollectionConfiguration CollectionConfiguration
{
CollectionName = $collectionName
CollectionDescription = $collectionDescription
ConnectionBroker = $localhost
TemporaryFoldersDeletedOnExit = $false
AuthenticateUsingNLA = $false
DisconnectedSessionLimitMin = 1
DependsOn = "[xRDSessionCollection]Collection"
}
xRDRemoteApp Notepad
{
CollectionName = $collectionName
DisplayName = "Notepad"
FilePath = "C:\Windows\System32\notepad.exe"
Alias = "notepad"
CommandLineSetting = "Allow"
DependsOn = "[xRDSessionCollection]Collection"
}
xRDRemoteApp Mstsc
{
CollectionName = $collectionName
DisplayName = "Remote Desktop Connection"
FilePath = "C:\Windows\System32\mstsc.exe"
Alias = "mstsc"
CommandLineSetting = "Require"
RequiredCommandLine = $commandLineParameter
DependsOn = "[xRDSessionCollection]Collection"
}
}
}