i have an array of strings representing files to copy. each one needs to be copied to a central location. i have code like...
the content for $file might look like "\\server\folder\file name.msi" and the content for $targetFolder would be something like "c:\temp"
the problem is that the copy-item command keeps failing with an error about invalid characters in path. it then shows the path to be a concatenation of the "path" and "destination", for example "c:\temp\\server\folder\file name.msi". if i use copy-item with the strings manually entered it works fine. i have confirmed the content of the variables $file and $targetFolder. but if i use copy-item with the variables it fails!?
any thoughts on why?
thanks,
glenn
Code:
foreach ($file in $files)
{
write-host "copying $file";
copy-item -path $file -destination $targetFolder
}
the content for $file might look like "\\server\folder\file name.msi" and the content for $targetFolder would be something like "c:\temp"
the problem is that the copy-item command keeps failing with an error about invalid characters in path. it then shows the path to be a concatenation of the "path" and "destination", for example "c:\temp\\server\folder\file name.msi". if i use copy-item with the strings manually entered it works fine. i have confirmed the content of the variables $file and $targetFolder. but if i use copy-item with the variables it fails!?
any thoughts on why?
thanks,
glenn