I have a custom module and want to load it in the command shell without having to call it explicitly each time I delve into Powershell.

Does it load automatically?

If not, how can I make it load automatically?


From PowerShell, evaluate the variable:


Verify that the directory specified in $profile exists, create the file if necessary (note: The directory and file are created by the user. Until you do so the first time neither the directory nor file will exist). Edit file specified by $profile in your favorite text editor. At the end of the profile add the line:

import-module <path-to-module>

If you use custom nouns/verbs and you want to avoid the noisy warnings just add the flag "-DisableNameChecking" to your import module call.

import-module <path-to-module> -DisableNameChecking

Now, reload your shell.

If you'd like to 'publish' your module so that you can import the module by name rather than by path then make a directory for your module under one of the directories in "$env:psmodulepath" (the one under windows is a system wide module repository) and copy your module file(s) there. Once you've done that you can import your module by name instead of by path.

import-module <name-of-module>

I think you have to do two things

  1. Add you module to your Documents folder (Documents\WindowsPowerShell\Modules)


  1. Modify your profile file (Documents\WindowsPowerShell\Profile.ps1) to have the include

eg Import-Module Pscx

And if that doesnt work try adding your import to:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\sharepoint.ps1

Thats the file the sharepoint powershell console imports

  • 1
    Editing the SharePoint.ps1 file stops my console from loading correctly so I suggest people don't try doing that. Jan 19 '11 at 11:09
  • Also, there's no Profile.ps1 in the location suggested (although the Interweb suggests there should be). Just to clarify I'm on a Win2008R2 server rather than Win7. Jan 19 '11 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.