Montag, 14. März 2011

My PowerShell Profile

Starbuck's Powershell profile
This article contains my growing PowerShell profile file. For those of you that are familiar with Unix shells this is a file similiar to .bashrc/.cshrc/... Per default executing this file this forbidden by policy, so you not to activate that. See this article for an interesting introduction to aliases and activation of profile files.

For the impatient reader execute the following command on a PS started as administrator:
Set-ExecutionPolicy Unrestricted 

And here is my (growing) Profile:

# implements a simple curl, lots of stuff still to do :)
function curl($url) {
    if($url){
        if(!$url.StartsWith("http://")) {
            $url = "http://" + $url;
        }
        return (new-object System.Net.WebClient).DownloadString($url);
    }
    else {
        return "Please provide a URL";
    }
}

# this is my tail -f
function tf ($file) {
    if($file) {
        get-content -wait $file;
    }
    else {
        write-host "Please provide a file to listen!";
    }
}