Don’t do that: The following code gets the parent container path of an AD user object.
Example: CN=Powershell Test,OU=Users,OU=Department,DC=domain,DC=com
$dn = (Get-ADUser -Identity $user -Properties DistinguishedName).DistinguishedName
$split = $dn -split '(?<![\\]),'
$split[1..$($split.Count-1)] -join ','
Do that: It can be done with a easier one-liner:
$parent = $dn.split(',',2)[1]