Copying files through a vm session using copy-item shows error when destination directory has wildcard (square bracket)
#powershell ver. 5.1.19041.2364
$vm_session = new-pssession -vmname $vmname -credential (get-credential)
$source_item = "c:\source\source.src"
#all destination paths below exist.
copy-item -literalpath $source_item -destination 'c:\[dest]\' -force;
#-> (O) no problem in the local session.
copy-item -literalpath $source_item -tosession $vm_session -destination 'c:\(dest]\' -force
#-> (O) Even in the vm session, it works fine with no square bracket path.
copy-item -literalpath $source_item -tosession $vm_session -destination 'c:\[dest]\' -force
#-> (X) In the vm session, It doesn't work with square brackets.
copy-item -literalpath $source_item -tosession $vm_session -destination 'c:\`[dest]\' -force
#-> (X) escaping square bracket is of no use.
$dest = [Management.Automation.WildcardPattern]::Escape('c:\[dest]\')
copy-item -literalpath $source_item -tosession $vm_session -destination $dest -force
#-> (X) escaping square bracket is of no use II.
Can this be solved? (I can not use copy-vmfile as of now)
thank you for reading.