PowerShell Hello World Script

by Buddy Lindsey on January 15, 2008

I have been wanting to learn PowerShell for a while now and one of the guys in the #alt.net irc channel talks about it all the time. So I decided to give it another shot.  The first thing I wanted to do was write a Hello World script that just out put that text to the screen running form a script file.  It wasn't so easy to figure it out believe it or not and there wasn't a good Hello World tutorial on the net I could find.  Finally, after a while of just trying stuff and following half instructions I figured out how to get a script to run.

First though you need to Download PowerShell. Please follow that how-to on downloading PowerShell.

After powershell is installed open up the powershell command window and notepad.  I'm not going to go into the why of powershell here because honestly I don't know yet.  Instead i'll give you quick instructions for writing a script that will run.

  • In notepad type out the following ( Write-Output "Hello World" ) without the parenthasis
  • Save file as HelloWorld.ps1
  • Switch to PowerShell command window
  • Navigate to the folder you saved the file in ( I just used C:\ to keep it easy at first )
  • Execute the following command: Set-ExecutionPolicy RemoteSigned (reduces security until you increase it.  There is a very annoying security policy in place for just dev work)
  • Next is to run the script just d: ./HelloWorld.ps1

It should have spit out Hello World do the console.  Congrats you just did a hello world script in powershell 

HelloWorld.ps1 (26.00 bytes)

Related Posts:

Leave a Comment

Previous post:

Next post: