KeyQ Blog

Exporting your ADFS Relying Party Trust configuration

Written by Kenneth Hough | Jun 6, 2022 8:46:00 PM

A quick search on exporting your ADFS relying party trust as an XML results in the command Get-AdfsRelyingTrust -Name.  Although this command is correct, you may run into an error indicating the command cannot be found. So, you figure that some ADFS module is missing, and continue your search for a solution.

In the example below, I have a Windows Server 2012r2 with ADFS version 3.0 configured where I encountered the missing command error. Let’s find out how to resolve the multiple issues I ran into last time I was exporting my configuration file.

Step 1. Add-PSSnapin Microsoft.Adfs.PowerShell

What you’ll soon find after some searching is that you need to add a PowerShell snap-in for ADFS.  This sounds straight forward, however, when executing Add-PSSnapin Microsoft.Adfs.PowerShell with elevated permission you get another error… 

Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 4

Step 2. Get-PSSnapin -Registered (just skip…)

Really, I recommend skipping this step.  Although many search results suggest you to confirm you have the snap in, the error states it’s missing in the first place so I doubt you’ll find much. In my scenario, running the command returned an empty list. 

Step 3. Get-Module -ListAvailable

If all the above suggestions that you encountered have failed, try running the Get-Module -ListAvailables command to get a list of available modules.  In the example below, you will see that ADFS is listed at the top – that’s good news!

Step 4. Get-Command -Noun “ADFS”

After confirming that the ADFS module is available, you’re ready to load it by running the Get-Command -Noun "ADFS". This command let’s you import all commands and functions that include the specified noun.

See the Microsoft documentation for more details: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/get-command?view=powershell-7.1

Step 5. Get-AdfsRelyingTrust

Finally, the only command left to run is to export your Relying Party Trust configuration and save as an XML.

(Get-AdfsRelyingTrust -Name <NameOfMyRelyingPartyTrust>) | Export-CliXML <SomePath>

And…voilà! Hopefully this article was helpful in resolving your issues with exporting your Relying Party Trust configurations.