Skip to content

Instantly share code, notes, and snippets.

@nivleshc
nivleshc / InstallADFS_JoinDomain.ps1
Created September 25, 2016 04:31
This function inside InstallADFS joins the virtual machine to the Active Directory domain
xComputer JoinDomain
{
Name = $MachineName
DomainName = $DomainName
Credential = $DomainCreds # Credential to join to domain
DependsOn = "[xWaitForADDomain]DscForestWait"
}
@nivleshc
nivleshc / InstallADFS_Reboot1
Created September 25, 2016 04:38
This function inside InstallADFS reboots the virtual machine after it has been joined to the Active Directory domain
xPendingReboot Reboot1
{
Name = "RebootServer"
DependsOn = "[xComputer]JoinDomain"
}
@nivleshc
nivleshc / InstallADFS_InstallADFS.ps1
Created September 25, 2016 04:40
This function inside InstallADFS installs the InstallADFS windows role
WindowsFeature installADFS #install ADFS
{
Ensure = "Present"
Name = "ADFS-Federation"
DependsOn = "[xPendingReboot]Reboot1"
}
@nivleshc
nivleshc / InstallADFS.ps1
Created September 25, 2016 04:49
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,
@nivleshc
nivleshc / ConfigureADFS_GetCredentials.ps1
Created September 25, 2016 11:05
Part of the ConfigureADFS.ps1 CSE where the credentials are obtained
#get the admin and adfs passwords first
$adminpassword = Convertto-SecureString -String (Get-Content -Path $($localpath+"adminpass.key")) -key $key
$adfspassword = Convertto-SecureString -String (Get-Content -Path $($localpath+"adfspass.key")) -key $key
$DomainAdminCreds = New-Object System.Management.Automation.PSCredential($($DomainName+"\"+$DomainAdminUsername), $adminpassword)
$AdfsSvcCreds = New-Object System.Management.Automation.PSCredential($($DomainName+"\"+$AdfsSvcUsername), $adfspassword)
@nivleshc
nivleshc / ConfigureADFS_ImportCertificate.ps1
Created September 25, 2016 11:12
Part of the ConfigureADFS.ps1 CSE. This shows how to import a certificate
#install the certificate that will be used for ADFS Service
Import-PfxCertificate -Exportable -Password $adminpassword -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"}
@nivleshc
nivleshc / ConfigureADFS_InstallADFSFarm.ps1
Created September 25, 2016 11:17
Part of the ConfigureADFS CSE. This part shows how to install the adfs farm
#Configure ADFS Farm
Import-Module ADFS
Install-AdfsFarm -CertificateThumbprint $cert.thumbprint -Credential $DomainAdminCreds `
-FederationServiceName fs.adfsfarm.com -FederationServiceDisplayName "Active Directory Federation Service" `
-ServiceAccountCredential $AdfsSvcCreds -OverwriteConfiguration
@nivleshc
nivleshc / ConfigureADFS.ps1
Created September 25, 2016 11:23
This CSE configures an ADFS Farm
param (
$DomainName,
$DomainAdminUsername,
$AdfsSvcUsername
)
#the domain admin and adfs service passwords are 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)
@nivleshc
nivleshc / InstallADFS_ARMTemplate.json
Last active September 25, 2016 11:34
ARM DSC extension to install ADFS
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(parameters('ADFS01VMName'),'/InstallADFS')]",
"apiVersion": "2015-05-01-preview",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('ADFS01VMName'))]"
],
"properties": {
"publisher": "Microsoft.Powershell",
@nivleshc
nivleshc / InstallADFS_ARM DSC Extension_variables.json
Created September 25, 2016 11:40
Variables used in the InstallADFS DSC extension
"repoLocation": "https://raw.githubusercontent.com/nivleshc/arm/master/",
"InstallADFSPackageURL": "[concat(parameters('repoLocation'), 'InstallADFS.zip')]",
"InstallADFSConfigurationFunction": "InstallADFS.ps1\\InstallADFS"