Skip to content

Instantly share code, notes, and snippets.

@CalvinRodo
Created January 19, 2012 18:19
Show Gist options
  • Save CalvinRodo/1641637 to your computer and use it in GitHub Desktop.
Save CalvinRodo/1641637 to your computer and use it in GitHub Desktop.
Improved Module Loading in Windows Powershell profile.
#Add the profile path to the environment path variable
$ProfileRoot = (Split-Path -Parent $MyInvocation.MyCommand.Path)
$env:path = ";$ProfileRoot"
#Load all of the modules from ./Modules/* that aren't already loaded.
(gci $ProfileRoot"/Modules") | ForEach { if ( -Not( Get-Module $_.Name ) ) { Import-Module $_.Name; Write-Host Importing Module: $_.Name } }
@shane0
Copy link

shane0 commented Sep 14, 2016

Pretty sure this will break existing paths, don't you mean this?

$env:path += ";$ProfileRoot"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment