Tuesday, May 31, 2011

Get-Help

I love Get-Help, I really do.

Microsoft has released an update of the CHM help file (PS2.0 Core Help May 2011 Update).  The CHM is easy to search and it is nice to be able to scroll through all of the pages especially when looking at examples.

Get-Help has a few distinguishing benefits over the CHM.  It is there at your fingertips when you are in the shell.  So to quickly to see what your formatted output options are, just "get-help out-*"

Get-Help is also dynamic.  It can grow to contain the functions of modules and PS1 files that have been Dot Included.

Take a look at either help method under "about_Comment_Based_Help".
Function HelloForm {
<#
    .Description 
     Use Winforms Form to show Hello World
#>
    Add-Type -AssemblyName "System.windows.forms"
    $form = New-Object System.Windows.Forms.Form
    $form.Text="Hello World"
    $form.ShowDialog()
}
Get-Help HelloForm

Good Explanation: http://technet.microsoft.com/en-us/magazine/ff458353.aspx

Saturday, May 28, 2011

Hello-World

Hello World...  The perfect sample app.

In PS you can do this a multitude of ways:
echo "Hello World"
Write-Output "Hello World"
# Echo and Write-Output are actually the same command.
#or just
"Hello World"
#or
("{0} {1}" -f "Hello","World")
# or Call .Net WinForms
Function HelloForm {
    [void][System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")
    $form = New-Object System.Windows.Forms.Form
    $form.Text="Hello World"
    $form.ShowDialog()
}
HelloForm

Thursday, May 26, 2011

Why PowerShell

Why should we use power shell... ?
PowerShell replaces the command prompt.
It replaces .bat and .cmd files.
It can automate administrative tasks.
It can be used to link business objects in dynamic configurations.
It can be a fun way to look at problems from a new perspective.