Skip to content

Instantly share code, notes, and snippets.

@infosec-intern
Created June 4, 2016 13:56
Show Gist options
  • Save infosec-intern/5b5fdb98dbec630cf68aa8b2add5866e to your computer and use it in GitHub Desktop.
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
$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"
@infosec-intern
Copy link
Author

Remove the last line and references to $Counter to keep this script quiet

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