A simple “Hello World” in PowerShell (extremely basic)

There are a couple of ways to do this in PowerShell:

PS C:\Scripts> Write-Output "Hello World" 

Output: Hello World

PS C:\Scripts> Write-Host "Hello World"

Output: Hello World

PS C:\Scripts> write “Hello World”

Output: Hello World 

Now to add a pause, waiting for the user to press any key prior to exiting the script.  This will be put into Hello-World.ps1.

Write-Host "Hello World"
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Output: PS C:\Scripts> ./Hello-World.ps1
Hello World
Press any key to continue ...


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.