How to Move Files from One Folder to Another Using PowerShell (With Date Filtering)

move files from one folder to another using powershell script

Managing files on Windows systems often involves organizing, archiving, or cleaning up folders based on file dates. For example, you might want to move files older than 30 days to an archive folder, separate last month’s reports, or relocate recently created files to another directory for processing. This is where PowerShell becomes extremely helpful. PowerShell … Read more

PowerShell Write-Host Color [With Examples]

powershell write-host without newline

You know what’s annoying? Staring at a PowerShell window filled with endless lines of white text on a blue background, trying to figure out which messages are errors, which are warnings, and which are just informational notes. I’ve been there. Running a script and missing a critical warning because everything looks the same. Or worse, … Read more

How to Check if a Process is Running in PowerShell

Check if a Process is Running in PowerShell

One of my team members was trying to check if a process is running in their system. PowerShell is best suitable for this. Today, I’m going to show you exactly how to check if a process is running using PowerShell. We’ll start with the basics and work our way up to some really practical examples … Read more

PowerShell Question Mark Operator: Ternary, ??, ?. and $?

PowerShell question mark operator examples

The question mark operator in PowerShell usually means the ternary operator, condition ? valueIfTrue : valueIfFalse. It picks one of two values in a single line, and it needs PowerShell 7 or later: Output: PowerShell also uses the question mark in ??, ??=, ?., as an alias and in $?. I cover each one below, … Read more

PowerShell Import-Csv and ForEach: Loop Through CSV Rows

PowerShell Import-Csv with foreach

To loop through a CSV file in PowerShell, read it with Import-Csv and use a foreach loop. Each row becomes an object, and each column header becomes a property: Output: The file customers.csv has the columns Id, Name, Company, State and Total, with four customers. I use it in every example below. I ran each … Read more

How to Clear PowerShell History (And Why You Might Want To)

Clear PowerShell History

If you’ve been using PowerShell for a while, you’ve probably noticed it remembers every command you’ve typed. That’s usually handy—until it’s not. Maybe you accidentally typed a password in plain text. Or perhaps your history is so cluttered you can’t find anything useful anymore. Whatever the reason, clearing your PowerShell history is simpler than you … Read more

How to Get All Properties of an Object in PowerShell

Get All Properties of an Object in PowerShell

If you’ve been working with PowerShell for a while, you’ve probably run into situations where you need to see what properties an object has. Today, I’m going to walk you through everything you need to know about getting all properties of an object in PowerShell. We will see different methods with examples. When you run … Read more

How to Convert Excel Files to CSV Using PowerShell (The Easy Way)

Convert Excel Files to CSV Using PowerShell

You know that moment when you need to convert dozens of Excel files to CSV format, and you’re thinking, “Great, I’ll be clicking ‘Save As’ for the next hour”? Yeah, I’ve been there too. Maybe you’re a data analyst who needs to feed CSV files into a database. Or perhaps you’re working with legacy systems … Read more

How to Check if a Port Is Open Using PowerShell (Fast Methods)

Check if a port is open using PowerShell

To check if a port is open using PowerShell, run Test-NetConnection with the host name and port. -InformationLevel Quiet returns just True or False: Output: That’s perfect for one check, but it can take 20 seconds or more when the port is closed. Below I show a faster check with a timeout, a reusable function, … Read more

PowerShell Cannot Index into a Null Array – How to Fix

powershell cannot index into a null array

Are you getting an error “Cannot index into a null array” in PowerShell? If yes, this is probably you’re trying to grab something from a container that doesn’t exist (or is empty). In this tutorial, I will explain what causes the “cannot index into a null array” error and how to fix it. Understanding the … Read more