Skip to content

Instantly share code, notes, and snippets.

@xorxornop
Created June 2, 2018 13:43
Show Gist options
  • Save xorxornop/a321c03ef5088da03e1de4c7749396fd to your computer and use it in GitHub Desktop.
Save xorxornop/a321c03ef5088da03e1de4c7749396fd to your computer and use it in GitHub Desktop.
Powershell profile 'subprofile' dot-sourcing functionality
# Any/all additional functionality desired for the profile may be added as seperate files in a subfolder (name specified below) for the sake of tidiness and ease of switching out functionality:
$subprofileScriptFolderName = "SubprofileScripts"
# Find any sub-profile scripts found in the relevant subfolder, should it exist and contain '*.ps1' scripts, and then dot-source each of them:
Resolve-Path -Path "$(Split-Path -Path $profile -Parent)\$subprofileScriptFolderName\*" | Where-Object {$_.Path.EndsWith(".ps1")} | ForEach-Object {
. $_.Path
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment