How to Create Multiple Folders in PowerShell (New-Item, Loops, CSV)

Create multiple folders in PowerShell

To create multiple folders in PowerShell, give New-Item a comma-separated list of paths: New-Item -ItemType Directory -Path C:\Data\A, C:\Data\B. The -Path parameter takes an array, so one command makes them all. For dozens of folders, read the names from a list, a number range or a CSV and loop over them. I tested each method … Read more

PowerShell Get-Process: List, Filter, Sort and Stop Processes

PowerShell Get-Process cmdlet

PowerShell Get-Process lists the processes running on your computer. Type Get-Process for all of them, or Get-Process -Name chrome for one app by name. Each result is a Process object you can sort, filter or stop. I’ll go through names, IDs, sorting by CPU and memory, owners, modules and remote computers. I ran each example … Read more

How to Extract URLs from an XML Sitemap Using PowerShell

Extract URLs from an XML sitemap using PowerShell

To extract URLs from an XML sitemap using PowerShell, cast the file to [xml] and read the loc element of every url entry: That returns every URL as plain text. Below I filter them by keyword, remove duplicates, handle sitemap index files, and save the list. I tested each step in PowerShell 7 and Windows … Read more

How to Sort Files by Date in PowerShell (Modified, Created, Newest)

Sort files by date in PowerShell

To sort files by date in PowerShell, pipe Get-ChildItem to Sort-Object LastWriteTime. Add -Descending to put the newest file first: LastWriteTime is the date modified you see in File Explorer. I set up a test folder with known dates and ran every example in PowerShell 7 and Windows PowerShell 5.1. Sort files by date modified … Read more

How to Uninstall Firefox Using PowerShell (Silent, winget, Remote)

Uninstall Firefox using PowerShell

To uninstall Firefox using PowerShell, run winget with Firefox’s package ID. –silent hides the uninstaller window: Without winget, run Firefox’s own uninstaller, helper.exe, with /S. Below I find the install first, build a safe uninstall function, and cover remote PCs. I tested the read-only parts in PowerShell 7 and Windows PowerShell 5.1. Check if Firefox … Read more

How to Check if a Process Is Running in PowerShell

Check if a process is running in PowerShell

To check if a process is running in PowerShell, call Get-Process with the name and turn the result into True or False. -ErrorAction SilentlyContinue hides the error when nothing matches: Use the process name without .exe, like explorer or chrome. Below I check several names, start a program only when it isn’t running, wait for … Read more