Skip to content

Instantly share code, notes, and snippets.

@nivleshc
nivleshc / ConfigureADFS_CSE Extension.json
Created September 25, 2016 11:44
ConfigureADFS CSE Extention
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(parameters('ADFS01VMName'),'/ConfigureADFS')]",
"apiVersion": "2015-05-01-preview",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('ADFS01VMName'))]",
"[concat('Microsoft.Compute/virtualMachines/', parameters('ADFS01VMName'),'/extensions/InstallADFS')]"
],
"properties": {
[System.Management.Automation.PSCredential]$DomainCreds = New-Object System.Management.Automation.PSCredential ("${DomainName}\$($Admincreds.UserName)", $Admincreds.Password
xWaitForADDomain DscForestWait
{
DomainName = $DomainName
DomainUserCredential= $DomainCreds
RetryCount = $RetryCount
RetryIntervalSec = $RetryIntervalSec
}
LocalConfigurationManager
{
ActionAfterReboot = 'ContinueConfiguration'
ConfigurationMode = 'ApplyOnly'
RebootNodeIfNeeded = $true
}
"domainName": {
"type": "string",
"metadata": {
"description": "The FQDN of the AD Domain created "
}
},
"adminUsername": {
"type": "string",
"metadata": {
"description": "The name of the Administrator of the new VM and Domain"
@nivleshc
nivleshc / ConfigureADFS_EncryptPassword.ps1
Last active September 27, 2016 07:29
This shows how to encrypt passwords using a key
$AdminSecurePassword = ConvertTo-SecureString {AdminPlainTextPassword} -AsPlainText -Force
ConvertFrom-SecureString $AdminSecurePassword -Key $key > adminpass.key
$ADFSSecurePassword = ConvertTo-SecureString {ADFSPlainTextPassword} -AsPlainText -Force
ConvertFrom-SecureString $ADFSSecurePassword -Key $key > adfspass.key
$adfspassword = Convertto-SecureString -String (Get-Content -Path $($localpath+"adfspass.key")) -key $key
$AdfsSvcCreds = New-Object System.Management.Automation.PSCredential($($DomainName+"\"+$AdfsSvcUsername), $adfspassword)
#install the certificate that will be used for ADFS Service
Import-PfxCertificate -Exportable -Password $adfspassword -CertStoreLocation cert:\localmachine\my -FilePath $($localpath+"adfs_certificate.pfx")
#get thumbprint of certificate
$cert = Get-ChildItem -Path Cert:\LocalMachine\my | ?{$_.Subject -eq "CN=fs.adfsfarm.com, OU=Free SSL, OU=Domain Control Validated"}
#Configure ADFS
Import-Module ADFS
Add-AdfsFarmNode -CertificateThumbprint $cert.thumbprint -ServiceAccountCredential $AdfsSvcCreds -PrimaryComputerName $PrimaryADFSServer
<#AddToADFSFarm.ps1
#>
param (
$DomainName,
$PrimaryADFSServer,
$AdfsSvcUsername
)
#the adfs service account password is encrypted and stored in a local folder
$localpath = "C:\Program Files\WindowsPowerShell\Modules\Certificates\"