I'm creating a script in PowerShell which is supposed to find a user's UPM folder and append .old to it (to facilitate a profile rebuild). 

The snippet below is the code that I have:

```
# Rename the UPM profile
Exit-PSSession
cd '\\SYLX-FS-01\D$\UPMProfiles'
$UPMPath = "$target.upm"
$UPMOld = "$target.upm.old"
if (Test-Path $UPMPath -IsValid) {
    if (Test-Path $UPMOld -IsValid) {
        Remove-Item $UPMOld
        Rename-Item $UPMPath -NewName $UPMOld
        Write-Host "Renamed UPMProfile"
    } else {
        Rename-Item $UPMPath -NewName $UPMOld
        Write-Host "Renamed UPMProfile"
    }
} else {
    # Write-Host "UPM Profile not found, no action has been taken on the file server."
    $UPM = "False"
}

```

Every time I run this it returns an error that the file could not be found.

```
Remove-Item : Cannot find path '\\SYLX-FS-01\D$\UPMProfiles\bill.odwyer.upm.old'
because it does not exist.
At line:8 char:20
+         Remove-Item <<<<  $UPMOld
    + CategoryInfo          : ObjectNotFound: (\\SYLX-FS-01...er.upm.old:String) [Remove-Item], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
```

As far as I can tell, it should only be going to line 8 if the `$UPMPath` exists, and if not then it should just skip to `else`. What am I missing?