Refactored Codes
How to print Hello World As PowerShell Script in Windows
This is a basic PowerShell script, when this script is run, it prints "Hello World". You can watch the youtube video, related to this post here. [embed]https://youtu.be/vjc1KeMy53k[/embed] Follow the following sequence.
  1. Open any editor.
  2. Type Write-Output "Hello World"
  3. Save the file as print-hello-world.ps1, or you can use any name you want, but the file extension should be .ps1.
  4. Open PowerShell
  5. Go To Location Where your script is saved.
  6. And run the script by just provining the file name and Hit Enter.
PS D:\LearningPowerShell\PowerShellBlogCode> .\print-hello-world.ps1
Hello World
PS D:\LearningPowerShell\PowerShellBlogCode>
PowerShell code Execution ScreenShot. [caption id="attachment_669" align="alignnone" width="1010"]ScreenShot Showing execution of powershell script. PowerShell Hello World Script[/caption]