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:

[cc lang=”powershell”]
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
[/cc]

Leave a Reply

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