Search PowerShellers and other PowerShell-related sites

Monday, March 26, 2007

Spring-cleaning of a PowerShell profile

After I read James Manning's post why share-able functions shouldn't be in your PowerShell profile, I have looked in my $profile. It was far from small file focused on prompt function, transcript function, one-liners and aliases. So, I created a few subfolders (AD, ISA, Exchange, Misc, Test...) for my scripts in WindowsPowerShell folder. Also, the functions found their place in dedicated folder Functions. The only thing that left is to put all folders with scripts in my path and to dot-source functions from Functions folder.


$profilehome = ([System.IO.FileInfo]$PROFILE).DirectoryName

dir $profilehome | where {$_.PsIsContainer -and ($_.name -ne "functions")} | %{$env:path += ";" + $profilehome + "\" + $_.name}

dir ($profilehome + "\functions") | where {!$_.PsIsContainer} |
%{. ($profilehome + "\functions\" + $_.name)}



$profile is now clean and tidy, and in James Manning's words - it's a far more robust, maintainable, shareable, and supportable situation than before.

1 comment:

Anonymous said...

Your style is so unique compared to many other people. Thank you for publishing when you have the opportunity,Guess I will just make this bookmarked.

Avira Phantom VPN Pro Crack

Crack Software

Pc License Keys