Tim Van Wassenhove

Passionate geek, interested in Technology. Proud father of two

17 Nov 2010

Load all script files at PowerShell startup

These days i have quite some scripts files that i want to be loaded each time i launch PowerShell. Windows PowerShell Profiles teaches me where i should store my $profile. Here is what it looks like:

# Lookup powershell scripts location
$UserProfile = (Get-ChildItem Env:UserProfile).Value;
$ScriptFolder = "$UserProfile\My documents\WindowsPowerShell";

# Source all .ps1 files in PowerShell profile folder  
Get-ChildItem $ScriptFolder -name -include '*.ps1' -exclude 'profile.ps1'   
| foreach { (. "$ScriptFolder\$_") };

# Configure environment for VS2010