I have all my scripts primarily on a flash drive (and some backups on computers at home/work). At the flash drive I have my profile script that creates all my custom conversion functions, drives etc.
What I want is to load the profile script from flash disk every time I run PowerShell.
So, the code in my $profile
at all the computers I work with looks like this:
#drive name of my flash; obviously different on each computer
$global:psflash = "g:\"
# if my flash disk is available, load my profile script from the flash disk
if (test-path $psflash) {
. (join-path $psflash 'dev\powershell\PsProfile.ps1')
}
The good side effect is that all my scripts can use the global variable $psflash
to import other scripts they depend on or other modules in the same way as done in my profile (using join-path
) any time later.