System administrators love a good shortcut, especially when it comes to alleviating the aggravation that comes with managing computers, solving user issues, and putting out fires around the office. Enter PowerShell.
The TL;DR:
Open Notepad and add a PowerShell command (e.g., Write-Host “Hello, World!”)
Save the file with a .ps1 extension
Open PowerShell as an admin and run: Set-ExecutionPolicy RemoteSigned
Execute the script: &”C:\Scripts\insert name of file.ps1”
While there’s no shortage of great scripting languages, PowerShell is a favorite among sysadmins, and for good reason. It powerful, versatile, and can run across platforms, making it a useful tool no matter if you’re primarily a Windows shop or juggling mixed environments. Sysadmins have too much on their plates as it is, so task automation is basically mandatory. So, if you’re ready to start learning PowerShell let’s start with the basics.
PowerShell saves scripts in the .ps1 format. Feel free to use your own custom folder and file names. For our demonstration, we created both a file and a folder:
C:\Scripts\My First Script.ps1
Step 1: Create a PowerShell script file and add a cmdlet
Create a PowerShell script file in an application like Notepad, and add the Write-Host
cmdlet. Cmdlet, pronounced “command+let”, is another word for a PowerShell command).
Write-Host "Hello, World!"

Step 2: Save and try to run the script
Once you’ve saved your .ps1 script file, it is time to run it in PowerShell terminal. It’s the easiest way to run PowerShell scripts.
How to open the PowerShell terminal in Windows
There are a few easy ways to launch PowerShell in Windows:
Option 1: From the Start menu
Click the Start button (or press the Windows key).
Type PowerShell.
Click Windows PowerShell from the search results.
Note: Right-click and choose Run as Administrator to avoid permission issues later.
Option 2: With a keyboard shortcut
Press Windows + R to open the Run dialog.
Type powershell and hit Enter.
This opens a regular PowerShell session. To run it as an admin, use the Start menu option.
Once the terminal is open your ready to run the script.
How to run your first PowerShell script
Enter the following command, replacing the path with the actual location of your script:
& "C:\Scripts\My First Script.ps1"
This tells PowerShell to run the file using the call operator (&
).
Note: You can also use the PowerShell ISE or VS Code, but for now, we’ll stick with the terminal since it’s the most straightforward.
You will get an error (Don’t panic!)
When you run that command. You should get an error like:
My First Script.ps1 cannot be loaded because running scripts is disabled on this system

Et cetera, et cetera, et cetera.
That’s normal. PowerShell blocks scripts from running by default for security reasons. But if there’s something else erroring, we go over how to handle errors with PowerShell.
Anyway, before your script can run you’ll need to update the execution policy, which we’ll cover in the next step.
Hopefully I haven’t lost you. You’re still there, right? Right?
Step 3: Modify the execution policy
To prevent malicious scripts from running on your system, PowerShell enforces an execution policy. To use our newly created script, we must modify our execution policy to allow our PowerShell example script to run.
There are four execution policies:
Restricted
: Scripts will not run. Period. (This is the default setting.)RemoteSigned
: Locally created scripts run. Scripts that were created on another machine will not run unless they are signed by a trusted publisher."Signed by a trusted publisher" means the script includes a verified digital signature from a known and trusted source.
AllSigned
: Scripts (including locally created scripts) only run if signed by a trusted publisher.Unrestricted
: All scripts run regardless of who created them and whether they’re signed.
Since our PowerShell script isn’t digitally signed, our options are RemoteSigned
and Unrestricted
. We are going to change it to RemoteSigned
.
To change the execution policy, open PowerShell as an administrator (the command fails otherwise), and run the following command:
Set-ExecutionPolicy RemoteSigned
The Set-ExecutionPolicy
cmdlet asks to verify that you really want to change the script execution policy. Go ahead and select Y for yes, then close and reopen your PowerShell window.
Step 4: Run your script, again
After restarting the PowerShell window, try running your .ps1 script again.
& "C:\Scripts\My First Script.ps1"
It should write back, "Hello, World!" to the Windows PowerShell console:

Congratulations — you just wrote your first PowerShell script!
Easily run PowerShell scripts on remote devices
Need to run your awesome PowerShell scripts on remote devices? PDQ Connect can easily execute PowerShell scripts on any managed device with an active internet connection.
PowerShell examples for beginners
When looking for ideas on what you can do with beginner scripts, just think about things you need to do manually and see if you can grab the information. One good quick win is checking the ACL of fileshare:
Get-Acl "\\fileshare\folder" | Select-Object -ExpandProperty Access
Or try clearing out a temp folder that is taking up space with unneeded documents:
Get-ChildItem C:\temp | Remove-Item
Or test if a registry key is on a machine:
Get-ItemProperty -Path "HKLM:\SOFTWARE\Admin Arsenal\PDQ Deploy"
Those are all quick wins that you can grab out of the box. The entire world opens once you dive into PowerShell modules and start with scripts against critical systems, like Azure, VMWare, AWS, or Active Directory.

Learn PowerShell with the pros
Even the most experienced PowerShell aficionados are constantly learning. Ready to dive into more advanced functions? Check out The PowerShell Podcast to learn more about key people, resources, and modules.
Take your next steps with PowerShell
You now have the amazing power to create and run your own scripts and cmdlets.
Want to learn even more (of course you do), here are some of the top PowerShell modules and our list of PowerShell cmdlets to get familiar with PowerShell functions, and how to use them. And check out The PowerShell Podcast and join us on the official PDQ Discord where we have virtual PowerShell meetups. The world of PowerShell is your oyster.