Good Morning,
I am having slight issues with a snippet I have written - it does not deal with spaces very well in the file-name:
I have moved all of the folders that do not have spaces in but I cannot do the same for the ones that do.
$ObsoleteFolders = Import-Csv C:\path\to\csv\ObsoleteFolderList.csv
ForEach ($Folder in $ObsoleteFolders)
{
$Name = $Folder.ObseleteFolderList
$Source = "'\\server\users$\$Name'"
cmd.exe /C "move $Source \\server\users$\UnusedHomeDirs"
}
If there is a space in the $Name variable I get the following output:
cmd.exe : The syntax of the command is incorrect.
Thanks very any help you can provide