If you often administer your AD FS 2.0 Federation Service using PowerShell, there is an easy way to automatically add the AD FS 2.0 PowerShell snap-in when the PowerShell console window is launched.


PowerShell loads a profile for the user when the console window is launched. We will be creating and modifying this PowerShell profile in order to automatically add the AD FS 2.0 PowerShell snap-in each time PowerShell is launched. 


  1.  Launch a PowerShell console window
  2. We must allow the execution of scripts on the system. The following command will achieve this:


    1. Options
    2. Unrestricted, RemoteSigned, AllSigned, Restricted, Default, Bypass, Undefined


      Set-ExecutionPolicy Unrestricted
  3. Execute the following command:
  • Take note of the path from step 3. It should be similar to the following:
  •  Create any needed directories and files needed to satisfy the profile path. For example, the WindowsPowerShell directory and Microsoft.PowerShell_profile.ps1 file do not exist by default.
  •  Edit Microsoft.PowerShell_profile.ps1 in your favorite text editor, and add the following line:
    Add-PsSnapin Microsoft.Adfs.PowerShell -ErrorAction SilentlyContinue
  • Save and Close Microsoft.PowerShell_profile.ps1, and close any open PowerShell console windows
  • Launch a PowerShell console window and test the solution by executing the following command:  
    Get-Command *ADFS*