tsunami

log in
history

PowerShell: Write-Screenshot

Luke Breuer
2008-12-20 11:11 UTC

Screenshots in 4 seconds
Requires the PowerShell Community Extensions.
function Write-Screenshot($fileName, [Switch]$force)
{
    $img = (get-clipboard -image);

    if ($img -eq $null)
    {
        throw 'clipboard does not contain an image';
    }
    
    $nameAndPath = "\\asp2\inetpub\labreuer\root\upload$fileName.png";
    
    if ((test-path $nameAndPath) -and (-not $force))
    {
        throw 'file exists and -force was not specified'
    }
    
    $img.save($nameAndPath);
    set-clipboard -text "http://luke.breuer.com/upload/$fileName.png";
}

set-alias sshot Write-Screenshot