Using PowerShell to Display “Hello World!”

A common task performed when learning a new language is how to display “Hello World!”. Creating such an application with PowerShell is simple. Type the following into a shell (you can omit lines starting with #. Everything after # is a comment) and press Enter:

image

PowerShell scripts can also be saved to a file and executed. Save this Hello World sample to HelloWorld.ps1. Use the standard command-line cd command to navigate to folder in which HelloWorld.ps1 is saved. To execute the script, type the following to the shell:

.\HelloWorld.ps1

Get Microsoft SharePoint 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.