1. Write Hello World script in PowerShell
- Click on Windows -> PowerShell ISE to start this application
- Type: Write-Host “Hello World!”
- Click on the “Run Script” button to execute the PowerShell script. There should be a message “Hello World!” displayed
2. Save the script to a PowerShell file and execute the file
- Save the above script at e.g. C:\PowerShell\HelloWorld.ps1 (C:\PowerShell was just a folder I created. You can create your own folder with a different name)
- Open the Windows PowerShell command line application
- Navigate to the PowerShell folder (cd C:\PowerShell)
- Type .\HelloWorld.ps1 and press enter to execute the PowerShell script
- There should be a message “Hello World!” displayed
3. Fix the file is not digitally signed issue
If there is an error message saying that the file cannot be loaded as it is not digitally signed:
Fix this issue by changing the Execution Policy temporarily or permanently.
3.1. Change Execution Policy temporarily
Execute the command: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass and run the script file again
3.2. Change Execution Policy permanently
Execute the command: Set-ExecutionPolicy unrestricted and run the script file again. Notes: you need to execute the command under Administrator mode (start Windows PowerShell with the “Run as administrator” option).