Created
June 4, 2016 13:56
-
-
Save infosec-intern/5b5fdb98dbec630cf68aa8b2add5866e to your computer and use it in GitHub Desktop.
Example script to load user-specific modules into your PowerShell profile. Tested in PowerShell v5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$RootDir = 'C:\Users\user\Documents\WindowsPowerShell' | |
$Counter=0 | |
ForEach ($Module in $(Get-ChildItem "$RootDir\Modules")) { | |
try { | |
Import-Module $Module\*.psd1 | |
} | |
catch { | |
Import-Module $Module\*.psm1 | |
} | |
$Counter++ | |
} | |
Write-Output "[*] Imported $Counter modules`n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Remove the last line and references to $Counter to keep this script quiet