Security, PKI, sys and network admins

How run Windows PowerShell and create your first PowerShell script

How to schedule Windows processes/applications to stop/shutdown via PowerShell

Windows PowerShell comes useful in my daily routine. This is a small step on showing you how to get started with Windows PowerShell and running PowerShell scripts. Let us begin :).

Run Windows PowerShell

  1. Press the Windows key and search for “Windows PowerShell”.
  2. Right-click the Windows PowerShell application and click “Run as Administrator”.
How to stop a Windows application using PowerShell - Run as Administrator
How to stop a Windows application using PowerShell – Run as Administrator

Alternatively, you can also run Windows PowerShell via cmd by typing “PowerShell”.

Create your first Windows PowerShell script

Create a new file called run_script but with a .ps1 extension. We’ll just output a simple “Hello, admin!” message using the Write-Host command:

Write-Host "Hello, admin!"

Run your first Windows Powershell script

Once you’ve finished writing your own first PowerShell script, you’ll need to run it. Inside your PowerShell console, navigate to where (using the cd command) you’ve saved your .ps1 script and execute it:

.\run_script.ps1

Alternatively, you can run the script by navigating to where you’ve saved it using your file browser/explorer, right-clicking it and choosing “Run with PowerShell”.

How to run a PowerShell script
How to run a PowerShell script

Leave a Reply

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