Skip to content

Instantly share code, notes, and snippets.

@vhusker
Last active March 12, 2016 16:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save vhusker/4d9a73c6a1a9d90e9aae to your computer and use it in GitHub Desktop.
Save vhusker/4d9a73c6a1a9d90e9aae to your computer and use it in GitHub Desktop.
Build Pull Server for a DSC Demo
$ConfigData =@{
AllNodes = @(
@{
NodeName = "localhost"
PSDSCAllowPlainTextPassword = $True
}
)
}
Configuration BuildLabPullServer{
param(
[parameter(Mandatory)]
[ValidateNotNullorEmpty()]
[string]$NodeName,
[parameter(Mandatory=$True)]
[ValidateNotNullorEmpty()]
[string]$ComputerName,
[parameter(Mandatory=$True)]
[ValidateNotNullorEmpty()]
[string]$Domain,
[parameter(Mandatory=$True)]
[ValidateNotNullorEmpty()]
[string]$IP,
[parameter(Mandatory=$True)]
[ValidateNotNullorEmpty()]
[string]$DNSIP,
[parameter(Mandatory=$True)]
[ValidateNotNullorEmpty()]
[string]$Gateway,
[parameter(Mandatory=$True)]
[ValidateNotNullorEmpty()]
[string]$Subnet
)
#unsecure, not safe or recommended way to do this
$Creds = ConvertTo-SecureString "Passw0rd!" -AsPlainText -Force
$DomainAdminCred = New-Object System.Management.Automation.PSCredential ("$Domain\Administrator", $Creds)
$SafeModeAdminCred = New-Object System.Management.Automation.PSCredential ("Administrator", $Creds)
Import-DscResource -ModuleName xActiveDirectory,xNetworking,xComputerManagement,xPendingReboot,xSystemSecurity,xRemoteDesktopAdmin,xTimeZone,xWinEventLog,xPSDesiredStateConfiguration
Node $NodeName{
LocalConfigurationManager{
RebootNodeifNeeded = $True
}
xIPAddress PULLServerIP{
IPAddress = $IP
DefaultGateway = $Gateway
SubnetMask = $Subnet
AddressFamily = "IPv4"
InterfaceAlias = "Ethernet"
}
xDNSServerAddress DomainDNS{
Address = $DNSIP
InterfaceAlias = "Ethernet"
AddressFamily = "IPv4"
}
File Scripts{
Ensure = "Present"
Type = "Directory"
DestinationPath = "C:\Scripts"
}
xIEESC SetAdminIEESC{
UserRole = "Administrators"
IsEnabled = $False
}
xUAC UAC{
Setting = "NeverNotifyAndDisableAll"
}
xTimeZone ServerTime{
TimeZone = "Central Standard Time"
}
xRemoteDesktopAdmin RemoteDesktopSettings
{
Ensure = "Present"
UserAuthentication = "Nonsecure"
}
WindowsFeature DSCServiceFeature{
Ensure = "Present"
Name = "DSC-Service"
}
xDSCWebService PSDSCPullServer{
Ensure = "Present"
EndpointName = "PSDSCPullServer"
Port = 8080
PhysicalPath = "$env:SystemDrive\inetpub\wwwroot\PSDSCPullServer"
CertificateThumbPrint = "AllowUnencryptedTraffic"
ModulePath = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Modules"
ConfigurationPath = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Configuration"
State = "Started"
DependsOn = "[WindowsFeature]DSCServiceFeature"
}
xDscWebService PSDSCComplianceServer{
Ensure = "Present"
EndpointName = "PSDSCComplianceServer"
Port = 9080
PhysicalPath = "$env:SystemDrive\inetpub\wwwroot\PSDSCComplianceServer"
CertificateThumbPrint = "AllowUnencryptedTraffic"
State = "Started"
IsComplianceServer = $true
DependsOn = ("[WindowsFeature]DSCServiceFeature","[xDSCWebService]PSDSCPullServer")
}
xComputer JoinDomain{
Name = $ComputerName
DomainName = $Domain
Credential = $DomainAdminCred
DependsOn = "[xIPAddress]PULLServerIP","[xDNSServerAddress]DomainDNS"
}
xPendingReboot DomainJoin{
Name = "Check for reboot after domain join"
}
}#Node
}#configuration
BuildLabPullServer -ConfigurationData $ConfigData -NodeName localhost -computername $YourComputerName -Domain $YourDomain -IP $YourIP -Gateway $YourGateway -Subnet 24 -DNSIP $YourDNSIP -OutputPath $YourPath
Set-DscLocalConfigurationManager -Path $YourPath
Get-DSCLocalConfigurationManager
Start-DscConfiguration -Wait -Force -Verbose -Path $YourPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment