Live Developer Training starts 5 October 2026. Seats are limited.Live training starts 5 OctReserve your seat →Reserve →

How to Remove Duplicate Objects from an Array in PowerShell?

powershell remove duplicate objects from array

Recently, while working on a PowerShell script, I got a requirement to remove duplicate objects from an array. I tried various methods, and in this tutorial, I will explain how to remove duplicate objects from an array in PowerShell using different methods with examples. To remove duplicate objects from an array in PowerShell, you can … read more…

How to Count the Number of Objects in an Array in PowerShell?

powershell count number of objects in array

In this PowerShell tutorial, I will explain to you how to count the number of objects in an array in PowerShell using different methods and real examples. To count the number of objects in an array in PowerShell, you can utilize either the .Count or .Length property of the array. Here’s a simple example: This will store the number … read more…

How to Remove the First and Last Item in an Array in PowerShell?

Remove Both the First and Last Item from the PowerShell Array

Arrays are collections of items accessed by index, and sometimes, you may need to manipulate these collections by removing elements from either the beginning or the end of the array. In this PowerShell tutorial, we’ll explore how to remove the first and last item in an array in PowerShell. Removing the First Item from an … read more…

How to Loop Through an Array of Objects in PowerShell?

loop through array of objects powershell

Recently, I was working with an array of objects in PowerShell where I was in need to loop through an array of objects in PowerShell. In this blog post, we’ll explore how to loop through an array of objects in PowerShell using various methods. To loop through an array of objects in PowerShell, you can … read more…

How to Split an Array into Smaller Arrays in PowerShell?

powershell split array into smaller arrays

Recently, while working on a PowerShell automation task, I got a requirement to split an array into smaller arrays in PowerShell. In this PowerShell tutorial, I will explain how to split an array into smaller arrays in PowerShell. To split an array into smaller arrays in PowerShell, you can use a loop to iterate over … read more…

How to Convert Multiline String to Array in PowerShell?

Convert Multiline String to Array in PowerShell

Do you need to convert multiline strings into arrays in PowerShell? In this PowerShell tutorial, I will explain to you different methods to convert a multiline string into an array in PowerShell. To convert a multiline string into an array in PowerShell, you can use the -split operator with a newline character as the delimiter. For example: … read more…

How to Replace a String in Text File with PowerShell?

Recently, I got a requirement of replacing a string in a text file using PowerShell. PowerShell offers a straightforward way to replace strings in text files using its various cmdlets and operators. Here’s a step-by-step tutorial on how to replace a string in a text file using PowerShell. To replace a string in a text … read more…

How To Sort Array Of Objects In PowerShell?

Sort Array of Objects Descending Order

Sorting an array of objects in PowerShell is a common task you will get while working with PowerShell. In this PowerShell tutorial, I will explain how to sort an array of objects in PowerShell using different methods and examples to make it easier for you to understand. To sort an array of objects in PowerShell, … read more…

How to Convert String to DateTime in PowerShell?

Convert String to DateTime in PowerShell

Sometimes, you might need to convert string to date in PowerShell. This PowerShell tutorial will explore various methods to convert strings into DateTime objects in PowerShell with real examples. To convert a string to a DateTime object in PowerShell, you can use the cast operator [datetime], the Parse method, or the ParseExact method for specific formats. For example, $dateTime = [datetime]”2024-01-20″ converts … read more…

How To Compare Array Of Objects In PowerShell?

Compare Array Of Objects In PowerShell

In this PowerShell tutorial, I will explain how to compare an array of objects in PowerShell. PowerShell provides a powerful cmdlet, Compare-Object, that can be used to compare two arrays of objects. To compare an array of objects in PowerShell, use the Compare-Object cmdlet with the -ReferenceObject and -DifferenceObject parameters to specify the two arrays you want to compare. You can … read more…

How to Get the Highest Number in an Array in PowerShell?

powershell get highest number in array

Recently, I got a requirement to get the highest number in an array in PowerShell. In this PowerShell tutorial, we’ll explore different methods to retrieve the highest number from an array in PowerShell with complete and real examples. To find the highest number in an array in PowerShell, you can use the Measure-Object cmdlet with the -Maximum parameter. For … read more…

How to Replace String in XML File using PowerShell?

There will be times when, as a developer, you may need to replace a string value in an XML file using PowerShell. In this PowerShell tutorial, I will show a complete example of how to replace a string in an XML file using PowerShell. PowerShell Replace String in XML File Let us try to understand … read more…

How to Get Unique Values from an Array in PowerShell?

powershell get unique values from array

When working with data in PowerShell, you might be required to get distinct values from the array in PowerShell. In this tutorial, we’ll explore different methods to get unique values from an array in PowerShell with complete real examples. To get unique values from an array in PowerShell, you can use the Select-Object cmdlet with the -Unique switch, which … read more…

How to Pass Objects to Functions in PowerShell? [Multiple Examples]

How to Pass Objects to Functions in PowerShell

In this PowerShell, we can create and use functions that can accept objects as parameters. In this PowerShell tutorial, I will explain how to pass objects to functions in PowerShell with examples. In PowerShell, you can pass objects to functions by defining parameters in the function that expect an object type. To pass an object, … read more…