Skip to content

Commit 3b8ec2a

Browse files
committed
feat: added examples from psgallery
1 parent 3c98ff2 commit 3b8ec2a

File tree

1,119 files changed

+78644
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,119 files changed

+78644
-0
lines changed

windows/ConfigureDNSServerConfig.ps1

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
configuration dns-server-config
2+
{
3+
Import-DscResource -ModuleName 'xDnsServer'
4+
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
5+
6+
Node dns-server-config
7+
{
8+
$ZoneData =
9+
@{
10+
PrimaryZone = 'Contoso.com';
11+
ARecords =
12+
@{
13+
'ARecord1' = '10.0.0.25';
14+
'ARecord2' = '10.0.0.26';
15+
'ARecord3' = '10.0.0.27'
16+
};
17+
CNameRecords =
18+
@{
19+
'www' = 'ARecord1';
20+
'wwwtest' = 'ARecord2';
21+
'wwwqa' = 'ARecord3'
22+
}
23+
},
24+
@{
25+
PrimaryZone = 'Fabrikam.com';
26+
ARecords =
27+
@{
28+
'ARecord1' = '10.0.0.35';
29+
'ARecord2' = '10.0.0.36';
30+
'ARecord3' = '10.0.0.37'
31+
};
32+
CNameRecords =
33+
@{
34+
'www' = 'ARecord1';
35+
'wwwtest' = 'ARecord2';
36+
'wwwqa' = 'ARecord3'
37+
}
38+
}
39+
40+
WindowsFeature DNS
41+
{
42+
Ensure = 'Present'
43+
Name = 'DNS'
44+
IncludeAllSubFeature = $true
45+
}
46+
47+
foreach ($Zone in $ZoneData)
48+
{
49+
xDnsServerPrimaryZone $Zone.PrimaryZone
50+
{
51+
Ensure = 'Present'
52+
Name = $Zone.PrimaryZone
53+
DependsOn = '[WindowsFeature]DNS'
54+
}
55+
56+
foreach ($ARecord in $Zone.ARecords.Keys)
57+
{
58+
xDnsRecord "$($Zone.PrimaryZone)_$ARecord"
59+
{
60+
Ensure = 'Present'
61+
Name = $ARecord
62+
Zone = $Zone.PrimaryZone
63+
Type = 'ARecord'
64+
Target = $Zone.ARecords[$ARecord]
65+
DependsOn = "[WindowsFeature]DNS","[xDnsServerPrimaryZone]$($Zone.PrimaryZone)"
66+
}
67+
}
68+
69+
foreach ($CNameRecord in $Zone.CNameRecords.Keys)
70+
{
71+
xDnsRecord "$($Zone.PrimaryZone)_$CNameRecord"
72+
{
73+
Ensure = 'Present'
74+
Name = $CNameRecord
75+
Zone = $Zone.PrimaryZone
76+
Type = 'CName'
77+
Target = $Zone.CNameRecords[$CNameRecord]
78+
DependsOn = "[WindowsFeature]DNS","[xDnsServerPrimaryZone]$($Zone.PrimaryZone)"
79+
}
80+
}
81+
}
82+
}
83+
}
84+
dns-server-config

windows/ConfigureFirewallConfig.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Configuration firewall-config
2+
{
3+
Import-DSCResource -ModuleName NetworkingDsc
4+
5+
Node firewall-config
6+
{
7+
Firewall EnableBuiltInFirewallRule
8+
{
9+
Name = 'IIS-WebServerRole-HTTP-In-TCP'
10+
Ensure = 'Present'
11+
Enabled = 'True'
12+
}
13+
}
14+
}
15+
firewall-config

windows/ConfigureIISServerConfig.ps1

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
configuration iis-server-config
2+
{
3+
Import-DscResource -ModuleName 'xWebAdministration'
4+
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
5+
6+
Node iis-server-config
7+
{
8+
WindowsFeature WebServer
9+
{
10+
Ensure = 'Present'
11+
Name = 'Web-Server'
12+
}
13+
14+
xWebSiteDefaults SiteDefaults
15+
{
16+
IsSingleInstance = 'Yes'
17+
LogFormat = 'IIS'
18+
LogDirectory = 'C:\inetpub\logs\LogFiles'
19+
TraceLogDirectory = 'C:\inetpub\logs\FailedReqLogFiles'
20+
DefaultApplicationPool = 'DefaultAppPool'
21+
AllowSubDirConfig = 'true'
22+
DependsOn = '[WindowsFeature]WebServer'
23+
}
24+
25+
xWebAppPoolDefaults PoolDefaults
26+
{
27+
IsSingleInstance = 'Yes'
28+
ManagedRuntimeVersion = 'v4.0'
29+
IdentityType = 'ApplicationPoolIdentity'
30+
DependsOn = '[WindowsFeature]WebServer'
31+
}
32+
33+
File WebContent
34+
{
35+
Ensure = "Present"
36+
SourcePath = $SourcePath
37+
DestinationPath = $DestinationPath
38+
Recurse = $true
39+
Type = "Directory"
40+
DependsOn = "[WindowsFeature]AspNet45"
41+
}
42+
43+
xWebsite NewWebsite
44+
{
45+
Ensure = "Present"
46+
Name = $WebSiteName
47+
State = "Started"
48+
PhysicalPath = $DestinationPath
49+
DependsOn = "[File]WebContent"
50+
BindingInfo = MSFT_xWebBindingInformation
51+
{
52+
Protocol = 'https'
53+
Port = '443'
54+
CertificateStoreName = 'MY'
55+
CertificateThumbprint = 'BB84DE3EC423DDDE90C08AB3C5A828692089493C'
56+
HostName = $Website
57+
IPAddress = '*'
58+
SSLFlags = '1'
59+
}
60+
}
61+
62+
}
63+
}
64+
iis-server-config

windows/DomainControllerConfig.ps1

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
configuration domain-controller-config
2+
{
3+
Import-DscResource -ModuleName 'ActiveDirectoryDsc'
4+
Import-DscResource -ModuleName 'StorageDsc'
5+
Import-DscResource -ModuleName 'ComputerManagementDsc'
6+
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
7+
8+
$demoAdministrator = "demo\demoadmin"
9+
$domainCredential = Get-Credential -Username $demoAdministrator -Message "Please type the password for $DemoAdministrator user"
10+
$safeModeCredential = $domainCredential
11+
12+
Node domain-controller-config
13+
{
14+
WindowsFeatureSet ADDSInstall
15+
{
16+
Ensure = 'Present'
17+
Name = "AD-Domain-Services","RSAT-AD-Tools","RSAT-AD-Tools","RSAT-ADDS","RSAT-AD-AdminCenter","RSAT-ADDS-Tools"
18+
IncludeAllSubFeature = $true
19+
}
20+
21+
WaitforDisk Disk1
22+
{
23+
DiskId = 1
24+
RetryIntervalSec = 10
25+
RetryCount = 30
26+
}
27+
28+
Disk DiskD
29+
{
30+
DiskId = 1
31+
AllowDestructive = $true
32+
ClearDisk = $true
33+
DriveLetter = 'D'
34+
DependsOn = '[WaitforDisk]Disk1'
35+
}
36+
37+
PendingReboot BeforeDC
38+
{
39+
Name = 'BeforeDC'
40+
SkipCcmClientSDK = $true
41+
DependsOn = '[WindowsFeatureSet]ADDSInstall','[Disk]DiskD'
42+
}
43+
44+
ADDomain Domain
45+
{
46+
DomainName = 'contoso.local'
47+
DomainNetBiosName = 'contoso'
48+
Credential = $domainCredential
49+
SafemodeAdministratorPassword = $safeModeCredential
50+
DatabasePath = 'D:\NTDS'
51+
LogPath = 'D:\NTDS'
52+
SysvolPath = 'D:\SYSVOL'
53+
DependsOn = '[WindowsFeatureSet]ADDSInstall','[Disk]DiskD','[PendingReboot]BeforeDC'
54+
}
55+
56+
ADUser demodomainadmin
57+
{
58+
UserName = 'demoAdmin'
59+
Password = $domainCredential
60+
PasswordNeverExpires = $true
61+
ChangePasswordAtLogon = $false
62+
DomainName = 'contoso.local'
63+
DependsOn = "[ADDomain]Domain"
64+
}
65+
66+
Registry DisableRDPNLA
67+
{
68+
Key = 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp'
69+
ValueName = 'UserAuthentication'
70+
ValueData = 0
71+
ValueType = 'Dword'
72+
Ensure = 'Present'
73+
DependsOn = '[ADDomain]Domain'
74+
}
75+
}
76+
}
77+
78+
$MyData =
79+
@{
80+
AllNodes =
81+
@(
82+
@{
83+
NodeName = 'DomainControllerConfig'
84+
PsDscAllowPlainTextPassword = $true
85+
PsDscAllowDomainUser = $true
86+
}
87+
)
88+
}
89+
domain-controller-config -ConfigurationData $MyData
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
configuration net-core-windows-server-config
2+
{
3+
Import-DscResource -ModuleName 'xWebAdministration'
4+
Import-DscResource -ModuleName 'ComputerManagementDsc'
5+
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
6+
7+
Node net-core-windows-server-config
8+
{
9+
WindowsFeature WebServer
10+
{
11+
Ensure = 'Present'
12+
Name = 'Web-Server'
13+
}
14+
15+
Package InstallDotNetCoreHostingBundle {
16+
Name = 'Microsoft ASP.NET Core Module'
17+
ProductId = '49FDA0AA-4653-4432-88BF-ADAA61DD5735'
18+
Arguments = "/quiet /norestart /log $env:TEMP\dnhosting_install.log"
19+
Path = 'https://download.microsoft.com/download/1/1/0/11046135-4207-40D3-A795-13ECEA741B32/DotNetCore.2.0.5-WindowsHosting.exe'
20+
DependsOn = '[WindowsFeature]WebServer'
21+
}
22+
23+
Environment DotNet
24+
{
25+
Name = 'Path'
26+
Ensure = 'Present'
27+
Value = 'C:\Program Files\dotnet\;'
28+
Path = $true
29+
DependsOn = '[Package]InstallDotNetCoreHostingBundle'
30+
}
31+
32+
PendingReboot AfterDotNetCoreHosting
33+
{
34+
Name = 'AfterDotNetCoreHosting'
35+
SkipCcmClientSDK = $true
36+
DependsOn = '[Package]InstallDotNetCoreHostingBundle'
37+
}
38+
39+
xWebsite DefaultSite
40+
{
41+
Ensure = 'Present'
42+
Name = 'Default Web Site'
43+
State = 'Stopped'
44+
PhysicalPath = 'C:\inetpub\wwwroot'
45+
DependsOn = '[WindowsFeature]WebServer'
46+
}
47+
48+
File Content
49+
{
50+
Ensure = 'Present'
51+
DestinationPath = 'c:\inetpub\content'
52+
Type = 'Directory'
53+
}
54+
55+
File Logs
56+
{
57+
Ensure = 'Present'
58+
DestinationPath = 'c:\inetpub\content\logs'
59+
Type = 'Directory'
60+
DependsOn = '[File]Content'
61+
}
62+
63+
xWebAppPool AppPool
64+
{
65+
Ensure = 'Present'
66+
Name = 'AppPool'
67+
State = 'Started'
68+
}
69+
70+
xWebsite Website
71+
{
72+
Ensure = 'Present'
73+
Name = 'Website'
74+
State = 'Started'
75+
PhysicalPath = 'c:\inetpub\content'
76+
BindingInfo = MSFT_xWebBindingInformation
77+
{
78+
Protocol = 'Http'
79+
Port = '80'
80+
IPAddress = '*'
81+
Hostname = '*'
82+
}
83+
DependsOn = '[File]Content','[xWebAppPool]AppPool'
84+
}
85+
86+
xWebApplication SampleApplication
87+
{
88+
Ensure = 'Present'
89+
Name = 'Application'
90+
WebAppPool = 'AppPool'
91+
Website = 'Website'
92+
PreloadEnabled = $true
93+
ServiceAutoStartEnabled = $true
94+
AuthenticationInfo = MSFT_xWebApplicationAuthenticationInformation
95+
{
96+
Anonymous = $true
97+
Basic = $false
98+
Digest = $false
99+
Windows = $false
100+
}
101+
SslFlags = ''
102+
PhysicalPath = 'c:\inetpub\content'
103+
DependsOn = '[xWebsite]WebSite','[xWebAppPool]AppPool'
104+
}
105+
}
106+
}
107+
net-core-windows-server-config

0 commit comments

Comments
 (0)