Windows PowerShell vs CMD: Key Differences With Examples

Windows PowerShell vs CMD

Windows PowerShell vs CMD comes down to one difference: CMD passes plain text between commands, while PowerShell passes .NET objects you can filter, sort and format. For anything beyond a quick one-liner, PowerShell is the better choice. CMD (cmd.exe, the Command Prompt) is still around for batch files and old habits. Below I compare the … Read more

Windows Terminal vs PowerShell: What’s the Difference?

Windows Terminal vs PowerShell

In Windows Terminal vs PowerShell, the difference is simple: Windows Terminal is the window, and PowerShell is the shell that runs inside it. Windows Terminal draws the text, tabs and panes, while PowerShell understands your commands and runs scripts. So it’s not really Windows Terminal or PowerShell. You run PowerShell in Windows Terminal, or in … Read more

How to Install Windows Updates Using PowerShell

Install Windows updates using PowerShell

To install Windows updates using PowerShell, use the Windows Update Agent built into Windows, or the community PSWindowsUpdate module. PSWindowsUpdate is the quickest. In an elevated window, install it once, then install every available update: -AutoReboot restarts the PC if an update needs it, so leave it off on machines people are using. Below I … Read more

How to Disable Windows Firewall Using PowerShell

Disable Windows Firewall using PowerShell

To disable Windows Firewall using PowerShell, open PowerShell as administrator and set all three firewall profiles to False: That leaves the PC unprotected, so turn it back on as soon as you’re done. Below I check the status, preview the change with -WhatIf, re-enable it, and show the safer option of changing one rule. My … Read more

PowerShell Test-Path: Check If a File or Folder Exists

PowerShell Test-Path examples

Test-Path is the PowerShell cmdlet that checks whether a file, folder or other path exists. It returns True or False, so it drops straight into an if statement: Output: It never throws an error for a missing path, which makes it the safest check before you read, copy or delete something. I ran each example … Read more

PowerShell Copy-Item: Copy Files and Folders (With Examples)

PowerShell Copy-Item with examples

Copy-Item is the PowerShell cmdlet that copies files and folders. Give it a -Path and a -Destination, and add -Recurse when you’re copying a folder with everything inside it: Output: That’s the whole idea. The details matter, though, because Copy-Item has a few habits that surprise people, like creating a file where you expected a … Read more

How to Set the Execution Policy in PowerShell

Set the execution policy in PowerShell

To set the execution policy in PowerShell for your own account, run Set-ExecutionPolicy with RemoteSigned and the CurrentUser scope. It doesn’t need administrator rights: RemoteSigned runs scripts you write and blocks unsigned scripts from the internet. Below I check the current policy, change it for one session only, deal with blocked downloads and explain each … Read more

PowerShell Format-Table: Columns, Sorting and Long Text

PowerShell Format-Table examples

Format-Table is the PowerShell cmdlet that shows command output as a table. Pipe objects to it and list the properties you want as columns. All the examples below use this small list of servers: With no properties listed, Format-Table shows every property that fits: Output: I ran the examples in real PowerShell 7.6 and Windows … Read more

PowerShell -match Operator: Regex Examples

PowerShell -match operator with examples

The PowerShell -match operator checks a string against a regular expression and returns True or False. When it matches, the matched text is saved in the automatic $Matches variable: Output: \d{4} means four digits, so the pattern finds the order number anywhere in the text. Below I cover case sensitivity, named groups, arrays, -notmatch, special … Read more