I have a powershell script that needs to rename its parent directory:
$currDir = pwd
Rename-Item $currDir "NewName"
When I run this, I get the error "Rename-Item : The process cannot access the file because it is being used by another process." I've also tried (to be sure it isn't because the current directory is set to the target directory):
$currDir = pwd
cd ..
Rename-Item $currDir "NewName"
cd "NewName"
It still gives me the same error. It seems to be doing this if the script resides inside the directory, regardless of what directory I cd into in the script. How can I get around this? I realize some answers will probably say "move the script outside the directory", but I'd really like to find a real solution if possible.