PowerShell – Arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Creating An Empty Array | |
$my_array = @(); | |
# Creating An Array With Values | |
$my_array = 1,2,3,"text",10; | |
# Adding Element To Existing Array | |
$my_array += "new value"; | |
# Sorting The Array | |
[array]::sort($my_array); | |
# OR | |
$my_array | sort | |
# Sorting and Removing Duplicates | |
$my_array | sort -unique | |
# Selecting Unique Values | |
$my_array | SELECT -unique |