I have a simple copy-item job that is moving a folder matching the $Username viable from one location to another. I am then trying to move a folder from one location to another on the copied data but i am seeing the error below. If I change the $UserName to the actual folder name the move is fine. Is there a reason it does not like the variable?
Move-Item : Cannot find path ‘D:\Migration-Folder$UserName\Documents\My Pictures’ because it does not
exist.
Ok so sticking the folders in a variable has move the move item work. Curious to know what it is about the move-item through as its the first time i have put a variable in that command.
Hi,
The path should be in quotation marks, single or double depending on whether it is static or dynamic - with a variable.
Why should the path be in quotation marks? mainly because of spaces in the folder name, e.g. “My Pictures”
What is the difference between single and double quotation marks: