I've looked at various sites that suggest that Sort-Object will return an array. This is not what I am seeing as when I do the below, the final output caused by the Sort-Object is just a single string. How can I sort the array into another array instead of to a string?
$myprogs = Get-ChildItem D:\MyPath\MyPrograms
$myprognames = foreach ($i in $myprogs) { $i.FullName -replace "D:\\MyPath\\MyPrograms\\", "" }
# At this point, $myprognames is a normal array
$myprognames = $myprognames | Sort-Object -Unique
$myprognames
# At this point, $myprognames is a single string with all elements stuck together, and if I select an element, like $myprognames[17], I will just get a single character as it's a string.
$i.FullName, that's just a string, so I'm creating an array of strings, right? Hence, I just want to sort the strings out into an ordered set of strings and save them as an array. The strings themselves are the set of objects that I want to sort alphabetically. i.e. I'm basically throwing away all of the properties that the Get-ChildItem returns and just want the.FullNamestrings. I don't see what you mean about not saving my changes, sorry?