PowerShell Hello World


This entry is part 2 of 9 in the series PowerShell

How do you display the string “hello world” at the console? Open a Windows PowerShell or PowerShell Core command prompt. To simple send a message to the screen type: Write-Output “hello world”. Another way to do this is to use Write-Host instead of Write-Output.

How do you get the version of the PowerShell you are using? You can use get-host. Just type get-host at the command prompt and press the Enter key. You could also use a variable. Type $psversiontable at the command prompt and press enter. You could drill down and just get the version with $psversiontable.psversion.

How do you check your operating system type on Windows? Are you using a 32-bit or 64-bit OS? Type set pro at the prompt. If you get an AMD64 as the PROCESSOR_ARCHITECTURE returned to you, you are on a 64-bit operating system.

You should use Write-Output instead of Write-Host. The only reason you would use Write-Host is if you needed to change the foreground or background color. However there is some controversy about ever even needing to use Write-Host at all.

Below is a screen shot. Click on it to see a larger image. The “hello world” for PowerShell is so simple that I thought I would include a variable and color.

Series Navigation<< Windows PowerShell IntroductionPowerShell ISE >>

Leave a Reply