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 Convert JSON to CSV in PowerShell (Nested JSON Too)

Convert JSON to CSV in PowerShell

To convert JSON to CSV in PowerShell, read the file as one string, turn it into objects with ConvertFrom-Json, and save them with Export-Csv: That works for flat JSON. Nested objects, dates and records with different fields need a little more, so I tested each case in PowerShell 7 and Windows PowerShell 5.1. Convert a … 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 Find SQL Server Instances Using PowerShell (Local, Network, Remote)

Find SQL Server instances using PowerShell

To find SQL Server instances using PowerShell on a server, read the Instance Names\SQL registry key. Every installed instance has a value there, named after the instance: To search a whole network instead, you’ll need Windows PowerShell 5.1 or the SQL tools. Below I cover the registry, services, the network search and remote servers, with … 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