I have a list of files to copy to/from different locations. Unfortunately, one of them has spaces in the subdirectory. Not all of them have subdirectories, and not all have spaces. This is a directory I can't rename because it's the VM directory and renaming it would involve removing and reinstalling the whole VM. This is what the script looks like.
$vDrive = "V:\VM - USA02xxxx\VM-USA02xxxx.vhd" $vDriveToLoc = "G:\" Copy-Item $vDrive $vDriveToLoc
The error message is Copy-Item: Access to the path 'V:\VM - USA02xxxx\VM-USA02xxxxx.vhd' is denied.
I'm administrator and have full control to the file/folders so that isn't the issue. It copies the files in the other directories fine.
I've tried replacing the double quotes with single quotes and it doesn't fix it. I've tried, with double quotes, to add back-ticks in front of each space. It didn't work.
I know that when I do this at the powerShell command line, it works to cd V:\ then cd "VM - USA02xxxx", but I can't do this programmatically for a long list of files/directories. Any ideas?
I saw this link but I'm not sure it would apply here: http://social.technet.microsoft.com/Forums/scriptcenter/en-US/71ec2cae-b126-4a4d-9622-169aa7c6b0ad/trying-to-copy-folderfiles-using-powershell?forum=winserverpowershell
I tried doing what one guy commented about here but it didn't work: https://stackoverflow.com/questions/3868342/running-an-exe-using-powershell-from-a-directory-with-spaces-in-it