Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.