移動從本地機文件時,文件服務器我想這些本地文件從系統上傳到文件服務器,但如果我嘗試使用Get-ChildItem我得到這個消息:遇到問題包括所有子項中使用PowerShell
對於 ,無法轉換參數「地址」,值爲:「System.Object []」,Downl將類型爲「System.Object []」 的「System.Object []」值轉換爲鍵入「Syste At C: \ Users \ Administrator \ Desktop \ MOVEFILES2.ps1:23 char:1 + $ WebClient.DownloadFile($ Source,$ Dest) + ~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ecified:(:) [],MethodException + FullyQualifiedErrorId:MethodArgumentConversionInvalidCastArgument
這裏是工作的腳本。我想修改它以便從該路徑拉出而不必指定文件名。
#UPLOAD FILES FROM SOURCE TO File server
# Specify the path to the documents you want to upload from the local machine...
$Source = "C:\Users\Administrator\Desktop\SourceFolder\Goober.docx"
$Dest = "\\10.112.4.111\xx\xxxxx\xxxx xxxxx\xxxx\Goober.docx"
# Specify Username and Password
$Username = "domain\user"
$Password = "xxxxxxxxxxx"
# Generate System.Net.WebClient object
$WebClient = New-Object System.Net.WebClient
$WebClient.Credentials = New-Object System.Net.NetworkCredential($Username, $Password)
$WebClient.DownloadFile($Source, $Dest)
是否有任何理由爲什麼你要調用webclient? Copy-Item或Move-Item也應該在unc路徑上工作?是同一個域的工作站和文件服務器成員,並且腳本將在哪兩個位置上運行權限的用戶? – Kage
我在不同的測試環境中移動,這就是爲什麼總是需要進行身份驗證。另外,我爲什麼選擇致電一個web客戶端。有另一種方法嗎? –
嗨,爲什麼不簡單地使用'Copy-Item'? – sodawillow