PowerShell Hello World

I had a comment left on one of my posts recently that mentioned a “Hello World” script. The concept of a Hello World program/script is that it is a simple introduction to using a new language that gives a known result.

For a brand new user to PowerShell is is how you create a Hello World script:

open PowerShell with elevated privileges (Run as Administrator)

type  Set-ExecutionPolicy RemoteSigned –Force and press enter

This enables scripts to run.

Run these two lines by typing them individually and pressing enter

New-Item -Path c:\ -Name TestScripts -ItemType Directory
cd C:\TestScripts

They create a test folder and move your location to that folder


“‘Hello World'” > script1.ps1

and press enter.  This creates your script. The single quotes nested in the double quotes are so that the text in the script will be surrounded by quotes – its a string value.

Run the script by typing


and pressing enter.  You will see the results:

Hello World

The .\ is required as PowerShell won’t run commands in the current folder by default. You have to explicitly give the local path.

You’ve now written your first PowerShell script and discovered most of the “gotchas” that cause people problems when they are first learning PowerShell

This entry was posted in Powershell Basics. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s