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?
|
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:
If you use custom nouns/verbs and you want to avoid the noisy warnings just add the flag "-DisableNameChecking" to your import module call.
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.
|
|||
|
|
|
I think you have to do two things
http://msdn.microsoft.com/en-us/library/dd878324%28v=vs.85%29.aspx
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 |
|||||
|