Subscribe to Blog via Email

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

Join 772 other subscribers


  • 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:


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(‘;’)

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 !


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

Copy modules to Scripts folder

This script copy's all the modules to your personal user module folder.



Place your modules in the folder : $BaseDir\Scripts\Modules 

Start copying the modules :

Start copying the modules and find more information :
.\Copy-Module.ps1 -Verbose


Written By:     Richard Voogt

Change Log
V1.0, 21-6-2015 - First version


        param ()

$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$BaseDir = (new-object $ScriptDir).parent.parent.fullname

Write-Verbose 'Starting Verbose output'
Write-Verbose "Setting basic Directory $BaseDir"
Write-Verbose "ScriptsLoc = $BaseDir\Scripts"

function Set-Location
    param ($Location)
    if(!(Test-Path -Path $Location )){
        Write-Warning "Creating Module location $Location."
        New-Item -ItemType directory -Path $Location
    ELSE {
        Write-Warning "Module location exists already exist in : $Location"

Function Copy-Modules
    Write-Verbose "Copy From : $BaseDir\Scripts\Modules"
    Write-Verbose "Copy to : $script:PSModulePad"
    Copy-Item "$BaseDir\Scripts\Modules\*" $script:PSModulePad -recurse -Force
    Write-Output "The modules are copied to $script:PSModulePad"

function Get-ModulePath
    param ()
    $UserPath = $env:PSModulePath.split(';')
    $HomeFolder = [environment]::getfolderpath('mydocuments')
    ForEach ($Script:PSModulePad in $UserPath) { 
                                Write-Verbose "homefolder = $HomeFolder"
                                Write-Verbose "psmodulepad = $Script:PSModulePad "
                                If ($Script:PSModulePad -like "*$HomeFolder*"
                                    Write-Verbose "psmodulepad2 = $Script:PSModulePad "
                                    Set-Location $Script:PSModulePad