Powershell snippets

Snippets of code gold

Posted by nick on September 03, 2019

Heres my list of snippets of Powershell;

Add all local modules to module path

When using import-module ABC, PowerShell goes off to the gallery and gets the module if it doesn't exist... but what if you are developing locally, this is not always desirable. You might have a modules path for example;


And you want to be able to execute import-module ModuleA

using this snippet at the start of your code should fix this;

$ModulesPath = "src\modules"
$env:PSModulePath = $env:PSModulePath + ";" + $ModulesPath

import-module ModuleA