How to Pass Variables to a PowerShell Script?

If you’re working with PowerShell regularly—whether for system administration, DevOps automation, or cloud management—you’ve likely encountered a situation where you need to make your scripts more dynamic. Instead of hardcoding values, you can pass variables to a PowerShell script at runtime. In this detailed tutorial, you’ll learn multiple ways to pass variables to PowerShell scripts, … Read more

PowerShell If Null Then Empty [With Examples]

powershell if null then empty

Recently, I was working on a PowerShell script that processed user information from our company database. I needed to handle cases where some fields might be null, and instead of letting these null values cause errors, I wanted to replace them with empty strings. This is a common scenario in PowerShell, especially when working with … Read more

How to Create an HTML Table from Variables in PowerShell?

create html table from variables using PowerShell

You can create an HTML table from variables in PowerShell to generate dynamic and readable reports. Whether you’re working with data from a SQL query, a CSV file, or a collection of objects, it is easy to convert this information into an HTML table in PowerShell. In this tutorial, I will explain how to create … Read more

How to Prompt for Variable in PowerShell?

powershell prompt for variable

Someone from the team asked about the PowerShell prompt for variables. We can do this by using the Read-Host cmdlet. In this tutorial, let me explain the PowerShell prompt for a variable with some examples. To prompt for a variable in PowerShell, use the Read-Host cmdlet. The basic syntax is $variable = Read-Host “Prompt message”, … Read more

How to Trim the Last 4 Characters from a Variable in PowerShell?

powershell trim last 4 characters from variable

In PowerShell, you might need to trim the last few characters from a string for various reasons, such as processing file names, user input, or any data where the trailing characters are not needed. This is a very common requirement among PowerShell developers. In this tutorial, I’ll explain how to trim the last 4 characters … Read more

How to Trim the First 4 Characters from a Variable in PowerShell?

Trim the First 4 Characters from a Variable in PowerShell

In PowerShell, you might encounter situations where you need to trim the first few characters from a string. One of my team members has exactly similar requirements. In this tutorial, I’ll explain how to trim the first 4 characters from a variable in PowerShell using different methods and practical examples. To trim the first 4 … Read more

PowerShell New-Variable Cmdlet [With Examples]

powershell new-variable

Today, I will explain a very useful cmdlet: the PowerShell new-variable cmdlet. You will learn about the syntax and usage with various real examples. The New-Variable cmdlet in PowerShell is used to create new variables. For a basic implementation, you can create a simple variable by using the command New-Variable -Name “Greeting” -Value “Hello, PowerShell!”, … Read more

How to Trim Variable Before Character in PowerShell?

powershell trim variable before character

When working with strings in PowerShell, you might need to trim or extract parts of a string before a specific character. One of my team members received this exact requirement. In this tutorial, I’ll explain how to trim a variable before a specific character in PowerShell using various methods and practical examples. To trim a … Read more

How to Trim Variable After Character in PowerShell?

PowerShell Trim Variable After Character

While working with PowerShell variables, I got a practical requirement to trim a variable after specific characters. I have used different methods to do this. In this tutorial, I will explain how to trim a variable after a specific character in PowerShell with examples. To trim a variable after a specific character in PowerShell, you … Read more

PowerShell If Variable Contains [With Examples]

PowerShell If Variable Contains

Previously I wrote a complete tutorial on PowerShell -contains Operator. Someone in my team asked more about PowerShell if variables contains. I thought I would explain everything about it with examples. To check if a variable contains a specific value in PowerShell, you can use the -contains operator. This operator is used to determine if … Read more

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.