Skip to content

Instantly share code, notes, and snippets.

@nivleshc
Created September 25, 2016 04:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nivleshc/6aa127ac83337e2a817fd7ce2804707c to your computer and use it in GitHub Desktop.
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
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