Management

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 785 other subscribers

Social

  • LinkedIn
  • RSS Feed for Posts
  • Twitter
  • StumbleUpon

Working with Powershell and modules. [Solved]

For some time now I worked with Functions in Powershell, but wanted to go to the next level, working with modules.

Creating modules isn’t rocket science, but working with modules the right way is something completely different.

At first is I placed my modules at C:\Windows\system32\WindowsPowerShell\v1.0\Modules\

But later I found out that this location is reserved for Windows powershell, and the future updates.

Personal modules should be placed in the location reserved for the personal modules.

To find the personal location there is a special command:

$env:PSModulePath.split(‘;’)

This command show you, all of the locations where Powershell can use modules, without needing to load them prior to using them.

PS C:\Users\%Username%> $env:PSModulePath.split(‘;’)
C:\Users\%Username%\Documents\WindowsPowerShell\Modules
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\

The first one ‘C:\Users\%Username%\Documents\WindowsPowerShell\Modules’ is the private location you can use for your private modules

The second one ‘C:\Windows\system32\WindowsPowerShell\v1.0\Modules\’ is the default for powershell, and should NOT be used by you !

When using more Powershell options, there could be more locations where windows stores modules :

C:\Program Files\Common Files\Microsoft Lync Server 2013\Modules\
C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement

These are the location for Microsoft Lync server and Microsoft Azure

When you redirect your documents folder, your WindowsPowerShell\Modules is also redirected.

So always check the private location ( Default is your Documents\WindowsPowerShell\Modules folder ), and place your private modules at this location !

TIP : Try using ISESteroids it is awesome !
http://www.vspbreda.nl/nl/2015/04/extend-your-powershell-ise-with-tons-of-extra-features-use-isesteroids-2-0/

Example:

This scripts copies your local modules to your prive module folder.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.