AD FS 2.0: How to Automatically Add the AD FS 2.0 Powershell Snap-in When Launching Powershell

AD FS 2.0: How to Automatically Add the AD FS 2.0 Powershell Snap-in When Launching Powershell


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.


Overview

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.


Steps

1. Launch a PowerShell console window

2. We must allow the execution of scripts on the system. The following command will achieve this:

        Set-ExecutionPolicy

        Options
        Unrestricted, RemoteSigned, AllSigned, Restricted, Default, Bypass, Undefined

        Example
        Set-ExecutionPolicy Unrestricted

3. Execute the following command:

        $PROFILE

4. Take note of the path from step 3. It should be similar to the following:

        C:\Users\<username>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

5. 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.

6. Edit Microsoft.PowerShell_profile.ps1 in your favorite text editor, and add the following line:

        Add-PsSnapin Microsoft.Adfs.PowerShell -ErrorAction SilentlyContinue

7. Save and Close Microsoft.PowerShell_profile.ps1, and close any open PowerShell console windows

8. Launch a PowerShell console window and test the solution by executing the following command:

        Get-Command *ADFS*


        
Leave a Comment
  • Please add 7 and 7 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
  • Richard Mueller edited Revision 2. Comment: Removed (en-US) from title

  • Craig Lussier edited Original. Comment: added en-US to tags and title

Page 1 of 1 (2 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Craig Lussier edited Original. Comment: added en-US to tags and title

  • Richard Mueller edited Revision 2. Comment: Removed (en-US) from title

Page 1 of 1 (2 items)