As I get more and more proficient with Windows PowerShell, I find that my profile is getting more and more useful. I thought I’d post my current profile’s content here, in case anyone finds any of these functions useful.
set-alias gh get-help
set-alias gcmd get-command
set-alias wo where-object
set-alias ss select-string
function sync {tfpt online /adds /deletes /diff "$args" /recursive /noprompt}
function kil {kill -name $args[0]}
function e {explorer $args[0]}
function sn { & 'C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe' $args }
function sn64 { & 'C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64\sn.exe' $args }
function prompt { "PS>" }
function hosts { notepad c:\windows\system32\drivers\etc\hosts }
function pro { notepad C:\Users\jkurtz\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 }
function gcp {get-content $args[0] | out-host -paging}
function edit { notepad $args[0] }
function npp { & 'C:\Program Files (x86)\Notepad++\notepad++.exe' $args }
function Replace-String($find, $replace, $path, $include)
{
ls $path -include $include –exclude *.dll,*.exe -recurse | select-string $find -list | % { echo "Processing contents of $($_.Path)"; (get-content $_.Path) | % { $_ -replace $find, $replace } | set-content $_.Path -Force }
ls $path *$find* -include $include -recurse |% { echo "Renaming $($_.FullName) to $($_.FullName.Replace($find, $replace))";mv $_.FullName $_.FullName.Replace($find, $replace) }
}
I also tend to keep a running list of change-directory functions handy. For example, if I am working on a project called “Popcorn”, I will create a function that lets me change the current directory to that project’s trunk – like this:
function cd-pc {cd c:\projects\popcorn\trunk; gl }
I realize I could use PowerShell drives. But I’m just not all that comfortable using drive letters – mapped drives in Windows or PowerShell drives.