Thanks to this forum, I have a script to sort an array of fully qualified file paths by just the filename portion.
$pattern = [regex]".+\\(.+)$"
$files = $files | Add-Member @{BaseName=$null} -PassThru
for ($i = 0; $i -lt $files.Count; $i++)
{
$files[$i] -match $pattern | Out-Null
$files[$i].basename = $Matches[1]
}
$files | sort BaseName
However the Add-Member fails when run on a machine running Powershell V2 - error below - can someone help me to reformat this line to run successfully on a V2 box?
Very new to Powershell...and very grateful for all your help!
Cannot bind parameter 'MemberType'. Cannot convert the "System.Collections.Hashtable" value of type "System.Collections.Hashtable" to type "System.Management.Automation.PSMemberTypes". ()