I am copying an .MSI file to a remote PC. The copy-item
is not retaining the filename or extension at the remote destination. I thought copy-item
would copy the file as is?
The script:
net use Q: \\remotePC\C$\Temp /user:USERID PSWD
copy-item C:\TEMP\installation.msi -Destination Q:\Temp
dir Q:\
net use Q: /delete
What the destination directory contains after the copy, a file called "Temp" with no extension.
Directory: Q:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 8/8/2012 3:57 PM 18900480 Temp
If I try to literally specify the filename in the destination of the copy-item
cmd I get the following error:
net use Q: \\remotePC\C$\Temp /user:USERID PSWD
copy-item C:\TEMP\installation.msi -Destination Q:\Temp\installation.msi
dir Q:\
net use Q: /delete
Error:
Copy-Item : Could not find a part of the path 'Q:\Temp\installation.msi'.
At P:\Powershell\CopyInstallFile\copyinstall.ps1:10 char:10
+ copy-item <<<< C:\TEMP\installation.msi -Destination Q:\Temp\installation.msi
+ CategoryInfo : NotSpecified: (:) [Copy-Item], DirectoryNotFound
Exception
+ FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.P
owerShell.Commands.CopyItemCommand
================================================================
EDIT - If I specify the full network path it copies the file correctly. Apparently the copy-item
doesn't like to use drives created by net use
copy-item C:\TEMP\installation.msi \\remotePC\C$\Temp