Month: May 2012

  • Windows forms, tips and trix – Buttons

    Ever written a GUI to your application? Ever think there are alot of unnecessary lines? Here is a smart way to add basic buttons without too many lines. function CreateButton{ param( $name, $text, $size, $location, $onclick, $Form ) $name = New-Object System.Windows.Forms.Button $name.Text = “$text” $name.Location = “$location” $name.Size = “$size” $name.add_Click($onclick) $Form.Controls.Add($name) } This requires…

  • wget for windows

    ever wanted to use wget in Powershell? This short function allows you to wget to local directory. function wget($urlpath){ $directory = (get-location).path $filename = $urlpath.Split(“/”)[-1] $file = $directory+”\”+$filename $webclient = New-Object System.Net.WebClient $webclient.DownloadFile($urlpath,$file) } Simply enter the function into your current powershell session and try it out. wget http://upload.wikimedia.org/wikipedia/en/f/f4/The_Scream.jpg If you want to permanently have access…

  • Powershell auto updater

    I wrote this short script to keep local scripts up to date with server versions. Makes it easier to handle scripts that are added with initial version through task sequence or other onetime distributions. The requirement is for the scripts to have the variable $CurrentVersion = <int/double> Example script, located on the central/repository: $CurrentVersion =…