Created
March 10, 2015 11:59
-
-
Save vhusker/c6560348976e56cd4daa to your computer and use it in GitHub Desktop.
Build App Server for a DSC Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ConfigData =@{ | |
AllNodes = @( | |
@{ | |
NodeName = "localhost" | |
PSDSCAllowPlainTextPassword = $True | |
} | |
) | |
} | |
Configuration BuildLabAppServer{ | |
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 xNetworking,xComputerManagement,xPendingReboot,xActiveDirectory | |
Node $NodeName{ | |
LocalConfigurationManager{ | |
RebootNodeIfNeeded = $True | |
} | |
xIPAddress APPIP{ | |
IPAddress = $IP | |
DefaultGateway = $Gateway | |
SubnetMask = $Subnet | |
AddressFamily = "IPv4" | |
InterfaceAlias = "Ethernet" | |
} | |
xDNSServerAddress DomainDNS{ | |
Address = $DNSIP | |
InterfaceAlias = "Ethernet" | |
AddressFamily = "IPv4" | |
} | |
xComputer RenameAndDomainJoin{ | |
Name = $ComputerName | |
DomainName = $Domain | |
Credential = $DomainAdminCred | |
DependsOn = "[xIPAddress]APPIP","[xDNSServerAddress]DomainDNS" | |
} | |
xPendingReboot DomainJoin{ | |
Name = "Check for reboot after domain join" | |
} | |
}#Node | |
}#configuration | |
BuildLabAppServer -ConfigurationData $ConfigData -NodeName localhost -computername $YourComputerName -Domain $YourDomain -IP $YourIP -Gateway $YourGateway -Subnet 24 -DNSIP $YourDNS -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