Created
September 25, 2016 04:49
-
-
Save nivleshc/6aa127ac83337e2a817fd7ce2804707c to your computer and use it in GitHub Desktop.
InstallADFS DSC script that adds a virtual machine to the Active Directory Domain and then installs the ADFS role on it
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
Configuration InstallADFS | |
{ | |
param | |
( | |
[Parameter(Mandatory)] | |
[string]$MachineName, | |
[Parameter(Mandatory)] | |
[string]$DomainName, | |
[Parameter(Mandatory)] | |
[System.Management.Automation.PSCredential]$Admincreds, | |
[Int]$RetryCount=20, | |
[Int]$RetryIntervalSec=30 | |
) | |
#Import the required DSC Resources | |
Import-DscResource -Module xActiveDirectory, xPendingReboot | |
[System.Management.Automation.PSCredential ]$DomainCreds = New-Object System.Management.Automation.PSCredential ("${DomainName}\$($Admincreds.UserName)", $Admincreds.Password) | |
Node localhost | |
{ | |
LocalConfigurationManager | |
{ | |
ActionAfterReboot = 'ContinueConfiguration' | |
ConfigurationMode = 'ApplyOnly' | |
RebootNodeIfNeeded = $true | |
} | |
xWaitForADDomain DscForestWait | |
{ | |
DomainName = $DomainName | |
DomainUserCredential= $DomainCreds | |
RetryCount = $RetryCount | |
RetryIntervalSec = $RetryIntervalSec | |
} | |
xComputer JoinDomain | |
{ | |
Name = $MachineName | |
DomainName = $DomainName | |
Credential = $DomainCreds # Credential to join to domain | |
DependsOn = "[xWaitForADDomain]DscForestWait" | |
} | |
xPendingReboot Reboot1 | |
{ | |
Name = "RebootServer" | |
DependsOn = "[xComputer]JoinDomain" | |
} | |
WindowsFeature installADFS #install ADFS | |
{ | |
Ensure = "Present" | |
Name = "ADFS-Federation" | |
DependsOn = "[xPendingReboot]Reboot1" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment