Hello-World.ps1
Hello-World.ps1
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 ...