Take a variable and break it up into 2 parts, store it in a simple array, and display values using PowerShell. Also, sort the array in descending order.
Input: "Hello-World"
variable one would be from 1st character of the input and up to the "-"
variable two would be from the character "-" to the end of the input variable
so
Output 1 would be "Hello"
Output 2 would be "World"
Program:
$string = Read-Host "Enter a String"
$varArray = $string.split("-")
#variable 1
$varArray[0]
#variable 2
$varArray[1]
#sorting the array
Write-Host "`nSorted Array in Descending Order:"
$varArray | Sort-Object -Descending