The following code will copy files to remote_computer if I use its IP address 10.10.10.10
$j = "remote_computer"
New-PSDrive -Name Z -PSProvider FileSystem -Root \\$j\share -Credential $credentials -ErrorAction Stop
Copy-Item -Path D:\ps_*able.ps1 -Destination \\10.10.10.10\share
Remove-PSDrive -name Z
This script will NOT copy over files if I use Z, the psdrive
$j = "remote_computer"
New-PSDrive -Name Z -PSProvider FileSystem -Root \\$j\share -Credential $credentials -ErrorAction Stop
Copy-Item -Path D:\ps_*able.ps1 -Destination Z
Remove-PSDrive -name Z
How to fix?
"Z" is not a valid path
Copy-Item -Path D:\ps_*able.ps1 -Destination Z:\