- PowerShell Tutorial
- PowerShell - Home
- PowerShell - Overview
- PowerShell - Environment Setup
- PowerShell - Cmdlets
- PowerShell - Files and Folders
- PowerShell - Dates and Timers
- PowerShell - Files I/O
- PowerShell - Advanced Cmdlets
- PowerShell - Scripting
- PowerShell - Special Variables
- PowerShell - Operators
- PowerShell - Looping
- PowerShell - Conditions
- PowerShell - Array
- PowerShell - Hashtables
- PowerShell - Regex
- PowerShell - Backtick
- PowerShell - Brackets
- PowerShell - Alias
- PowerShell Useful Resources
- PowerShell - Quick Guide
- PowerShell - Useful Resources
- PowerShell - Discussion
Powershell - Get-Unique Cmdlet
Cmdlet
Get-Unique cmdlet can be used to get the unique objects from a sorted list of objects.
In this example, we're see the Get-Unique cmdlet in action.
Step 1
In this example, we're set list of strings in a variable.
Type the following command in PowerShell ISE Console
$list = "one","two","two","three","four","five"
Step 2
In this example, we're printing the original list of strings.
Type the following command in PowerShell ISE Console
$list
Output
You can see following output in PowerShell console.
one two two three four five
Step 3
In this example, we're sorting the list and then get the unique values.
Type the following command in PowerShell ISE Console
$list | sort | get-unique
Output
You can see following output in PowerShell console.
five four one three two
powershell_advanced_cmdlets.htm
Advertisements