How to Keep Your Screen Active with a PowerShell Script

Keep your screen active with a PowerShell script

To keep your screen active with a PowerShell script, ask Windows directly with the SetThreadExecutionState API. It keeps the display and PC awake while the script runs, and everything goes back to normal when it stops: That’s better than the common trick of pressing a fake key every minute. Below I check your current timeouts, … Read more

How to Open a File in PowerShell (Default App, Notepad, Console)

Open a file in PowerShell

To open a file in PowerShell with its default app, run Invoke-Item with the file’s path. It works like double-clicking the file in File Explorer: Below I show how to preview what will open, open a file in a specific app, and read files right in the console. I tested each command in PowerShell 7.6 … Read more

How to Set Folder Permissions Using PowerShell (Get-Acl, Set-Acl)

Set folder permissions using PowerShell

To set folder permissions using PowerShell, read the folder’s ACL with Get-Acl, add a FileSystemAccessRule, and write it back with Set-Acl. This grants the Users group Modify on a folder and everything inside it: Below I view permissions, grant and remove access, control inheritance and do the same with icacls. I tested everything on a … Read more

PowerShell Regex: How to Use Regular Expressions (With Examples)

PowerShell regex examples

PowerShell regex (regular expressions) lets you match, extract, replace and split text by pattern. The operators -match, -replace and -split all take a regex, and $Matches holds what -match found: Output: Below I cover case sensitivity, named groups, replacing, splitting, finding every match, Select-String and switch -Regex. Every example ran in PowerShell 7.6 and 5.1, … Read more

How to Get the .NET Version Using PowerShell (Framework and .NET)

Get the .NET version using PowerShell

To get the .NET version using PowerShell, check two things: the .NET Framework version in the registry, and the modern .NET runtimes with dotnet –list-runtimes. Windows can have both installed side by side. Below I show both checks, plus how to see which .NET your PowerShell session runs on. I ran them on Windows 11 … Read more

How to Get the BIOS Serial Number Using PowerShell

Get the BIOS serial number using PowerShell

To get the BIOS serial number using PowerShell, read the SerialNumber property of the Win32_BIOS class. One line does it, with no admin rights needed: Output: That’s the same number printed on the sticker of most laptops and desktops. Below I compare the other places Windows stores serials, replace the old wmic command, and collect … Read more

How to Get an IP Address Using PowerShell in Windows

Get an IP address using PowerShell

To get your IP address using PowerShell, run Get-NetIPConfiguration and read the IPv4 address of the adapter that has a default gateway. That’s the address your PC uses on the network: Below I list every address, get the main one with its gateway, return just the address for scripts, and check remote PCs and your … Read more

PowerShell: Get the Current Logged-On User on a Remote Computer

Get the current logged-on user on a remote computer with PowerShell

To get the current logged-on user on a remote computer with PowerShell, read the UserName property of Win32_ComputerSystem with Get-CimInstance: It returns DOMAIN\user for whoever is signed in at the console. Below I test the same queries on my own PC, show the two remoting errors you’ll most likely hit, and cover Remote Desktop sessions … Read more

Why Does Windows PowerShell Keep Popping Up? (Find and Fix It)

Why Windows PowerShell keeps popping up

Windows PowerShell keeps popping up because something on your PC is starting it: usually a scheduled task, a startup entry, or an app or management script running in the background. Occasionally it’s malware. The fix is to find what launches it. Below I show three read-only checks that do exactly that, then how to stop … Read more

How to Update PowerShell on Windows 11 (winget, MSI or Store)

Update PowerShell on Windows 11

To update PowerShell on Windows 11, run winget upgrade for the PowerShell package. It installs the newest PowerShell 7 release over your current one: Before you run it, check which version you have and how it was installed, because Microsoft recommends upgrading with the same method. I walk through both checks below, plus the MSI, … Read more