Skip to content

Instantly share code, notes, and snippets.

@nivleshc
Created November 29, 2016 11:08
Show Gist options
  • Select an option

  • Save nivleshc/a35481615b4455c8cc3bb9782210145f to your computer and use it in GitHub Desktop.

Select an option

Save nivleshc/a35481615b4455c8cc3bb9782210145f to your computer and use it in GitHub Desktop.
Configure WAP Service
<#
ConfigureWAP.ps1 is passed the username for an account that has local administrator access on the ADFS Server
#>
param
(
$AdminUsername
)
#password for the local administrator account on the ADFS server is encrypted and stored in a local folder
#define the directory where the files are stored and the key used to encrypt the password, so that the password
#can be decrypted
$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)
#read in the contents of the file containing the encypted password for the account with local administrator
#access on the ADFS Server, and decrypt the password using the key
$adminpassword = Convertto-SecureString -String (Get-Content -Path $($localpath+"adminpass.key")) -key $key
#Create a PSCredential Object using the account username and password
$AdminCreds = New-Object System.Management.Automation.PSCredential($($AdminUsername), $adminpassword)
#import the certificate that was used to create the ADFS Farm
Import-PfxCertificate -Exportable -Password $adminpassword -CertStoreLocation cert:\localmachine\my -FilePath $($localpath+"fs.adfsfarm.com.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"}
Install-WebApplicationProxy -FederationServiceName fs.adfsfarm.com -FederationServiceTrustCredential $AdminCreds -CertificateThumbprint $cert.thumbprint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment