ReachIT-PS-ExecPolicy

PowerShell: Export and Import ADFS 2.0 settings.

Posted on Posted in Scripts, Uncategorized

Hi Guys,

A recent upgrade from ADFS 2.0 to ADFS 3.0 meant we needed an easy way to migrate existing configurations to the new federation services. This is a huge time save and avoids good old human error.

It’s never fun when SSO breaks for a whole application because  “l” (lower case L) got replaced with and “I” (upper case i). Yes, its pretty much indecipherable in the default MS font!

Check out the script below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Function Test-ADPassword {
$Cred = Get-Credential -Message "Enter Domain Credentials"
$Username = $Cred.username
$Password = $Cred.GetNetworkCredential().password

# Get current domain using logged-on user's credentials
$CurrentDomain = "LDAP://" + ([ADSI]"").distinguishedName
$Domain = New-Object System.DirectoryServices.DirectoryEntry($CurrentDomain,$Username,$Password)
$DomainName = $Domain.name

if ($Domain.name -eq $null)
{
write-host "Authentication failed for $Username - please verify your username and password." -BackgroundColor Black -ForegroundColor Red
}
else
{
write-host "The account $Username successfully authenticated against the domain: $DomainName" -BackgroundColor Black -ForegroundColor Green
}
$Password = $null
}
Test-ADPassword

Pause

One thought on “PowerShell: Export and Import ADFS 2.0 settings.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.