2014-09-18 62 views
0

下面的代碼將文件複製到REMOTE_COMPUTER如果我使用它的IP地址10.10.10.10拷貝項目適用於IP地址,而不是計算機名稱

$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 

這個腳本不會在文件複製如果我使用Z, 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 

如何解決?

回答

2

「Z」 不是一個有效的路徑

Copy-Item -Path D:\ps_*able.ps1 -Destination Z:\ 
+0

我試過了, 「Z:\」 和'\\ $ J□\ share',甚至'\\ remote_ip \ share'但沒有運氣 – Glowie 2014-09-18 18:25:11

+0

所以你本身只嘗試z:\?你的格式不正確。如果你是,而且它不工作,你會得到什麼錯誤?這聽起來像新psdrive實際上沒有映射任何東西。 – 2014-09-18 18:29:24

+0

是的,z:\本身。 New-PSDrive的輸出顯示名稱爲'Z'和Root'\\ remote_ip \ share' ...即使我不使用Z:\,而是使用計算機名稱或保存計算機名稱的變量,'Copy-Item'不起作用 – Glowie 2014-09-18 18:31:05

相關問題