Last active
August 12, 2018 06:59
-
-
Save nivleshc/2a86e632b9114cbeae915c65c2e0cbff to your computer and use it in GitHub Desktop.
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
<#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\" | |
$Key = (3,4,2,3,56,34,254,222,1,1,2,23,42,54,33,233,1,34,2,7,6,5,35,43) | |
#lets get the password and decrypt it | |
#get the adfs password first | |
$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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment