Reputation: 685
In one of my script, it tries to copy an exe to C:\Windows\Temp folder. For example:
Copy-Item repo\filename.exe -Destination \\$machine_name\C$\Windows\Temp
Error Message:
Copy-Item : The network path was not found.
At D:\CMPortal\Scripts\ClientRepair\RepairCCMClient.ps1:122 char:33
+ if(Copy-Item <<<< cmsetup.exe -Destination \\$install_cmexec\C$\Windows\Temp)
+ CategoryInfo : NotSpecified: (:) [Copy-Item], IOException
+ FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand
When I run the same command manually, it works. Dont know whats wrong. Is there any to overwrite the file if the copying file exists in the destination?
Thanks in advance.
Upvotes: 3
Views: 5651
Reputation: 2166
Are you using the quotes correctly?
Copy-Item 'repo\filename.exe' -Destination "\\$machine_name\C`$\Windows\Temp" -Force
Upvotes: 4
Reputation: 126732
Does $install_cmexec contains a server name? Also, make sure the user who runs the script has the appropriate permissions on the target path.
Upvotes: 1