How to Check if a String Starts with a Number in PowerShell?

powershell check if string starts with number

While working with string manipulations in PowerShell, I got a requirement to determine if a string starts with a number. In this tutorial, we will explore different methods to check if a string starts with a number in PowerShell with examples. To check if a string starts with a number in PowerShell, you can use … Read more

How to Check if a String Contains Only Numbers in PowerShell?

powershell check if string contains only numbers

One of my team members was searching for a PowerShell script to check if a string contained only numeric characters. I suggested a few methods. In this tutorial, I will explain how to check if a string contains only numbers in PowerShell using various methods. To check if a string contains only numbers in PowerShell, … Read more

PowerShell Filter Operators (With Examples)

PowerShell filter operators with examples

PowerShell filter operators are the comparison operators, like -eq, -gt, -like, -match and -in, used to keep only the items you want. Put them inside Where-Object, or apply them straight to an array: Output: When the left side is an array, the operator returns the matching items instead of True or False. Below I cover … Read more

PowerShell Arithmetic Operators: +, -, *, /, %, ++ and More

PowerShell arithmetic operators examples

PowerShell arithmetic operators are + for addition, – for subtraction, * for multiplication, / for division and % for the remainder (modulus). They work on numbers the way you’d expect: Output: They also have a few PowerShell-specific habits, like division that returns decimals and + that joins strings. I ran every example in PowerShell 7.6 … Read more

PowerShell Logical Operators: -and, -or, -not, -xor and !

PowerShell logical operators

PowerShell’s logical operators are -and, -or, -xor, -not and !. They combine or flip True/False conditions, mostly inside if statements and Where-Object filters: Output: ! is just a shorter spelling of -not. I ran every example in PowerShell 7.6 and Windows PowerShell 5.1, with the same results except the last section. What each logical operator … Read more

PowerShell Comparison Operators: -eq, -ne, -gt, -ge, -lt, -le

PowerShell comparison operators

PowerShell’s comparison operators are -eq (equal), -ne (not equal), -gt (greater than), -ge (greater than or equal), -lt (less than) and -le (less than or equal). Each returns True or False: Output: PowerShell uses these letter operators instead of =, > and <, which mean something else here. I ran every example in PowerShell 7.6 … Read more