How to Find Ports in Use with PowerShell

Find ports in use with PowerShell

To find which ports are in use with PowerShell, list the listening TCP ports with Get-NetTCPConnection and add the process that owns each one: Below I find who’s using one specific port, write a quick in-use test, check UDP ports, compare with netstat and test ports on other computers. A list of my own PC’s … Read more

How to Find the Location of an Executable in PowerShell

Find the location of an executable in PowerShell

To find the location of an executable in PowerShell, run Get-Command and read its Source property. It searches the folders in your PATH, just like running the program does: Output: Below I look up several programs at once, list every copy with -All and where.exe, and find where a running program lives. I used only … Read more

How to Find the Most Recent File in a Directory with PowerShell

Find the most recent file in a folder with PowerShell

To find the most recent file in a directory with PowerShell, list the files with Get-ChildItem, sort them by LastWriteTime from newest to oldest, and keep the first one: Output: LastWriteTime is the date Windows shows as Date modified. I ran every example in PowerShell 7.6 and Windows PowerShell 5.1 against the same sample folder, … Read more

How to Get All Properties of an Object in PowerShell

Get all properties of an object in PowerShell

To get all properties of an object in PowerShell, pipe it to Format-List with an asterisk. You get every property name with its value: To see just the names and types, use Get-Member -MemberType Property instead. Below I compare both, loop through properties in a script, find hidden members and dig into nested objects. I … Read more

How to Get BIOS Information Using PowerShell

Get BIOS information using PowerShell

To get BIOS information using PowerShell, query the Win32_BIOS class with Get-CimInstance. It shows the manufacturer, BIOS version, release date and serial number without a restart: It works without admin rights in PowerShell 7 and 5.1. Below I pick the useful properties, check UEFI and Secure Boot, query remote PCs and build an inventory report. … Read more

How to Move a File to a Folder in PowerShell

Move a file to a folder in PowerShell

To move a file to a folder in PowerShell, use Move-Item with the file in -Path and the folder in -Destination. The file keeps its name and disappears from the original folder: Output: That’s the whole job when everything is where you expect. The rest of this guide covers the cases that go wrong. I … Read more