我試圖從我的服務器上覆制一些文件到工作站。如果我將$Foldername
更改爲C:\
,則該過程正常工作。但是,如果我以這種方式保留代碼,即如果我決定將文件複製到C:\Program Files\Interrogator
。訪問被拒絕 - 混淆了COPY-ITEM
我得到這個錯誤:
Copy-Item : Access to the path 'C:\Program Files\Interrogator\Setup Instructions.txt' is denied.
At C:\Users\coduy\Desktop\Copy2Test.ps1:20 char:10
+ Copy-Item <<<< -Path \\10.10.0.10\DeploymentShare\Applications\JDE-Interrogator\* -Destination $Foldername
+ CategoryInfo : PermissionDenied: (\\10.10.0.10\De...nstructions.txt:FileInfo) [Copy-Item], Unauthorized
AccessException
+ FullyQualifiedErrorId : CopyFileInfoItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.CopyItemCommand
我可以看到,訪問被拒絕,但爲什麼呢?我沒有共享任何文件夾,如果我決定要複製到發現,其他用戶也有類似的問題C:\
或C:\Program Files
$net = New-Object -comobject Wscript.Network
$net.MapNetworkDrive("Z:","\\10.13.0.10\DeploymentShare\Applications\JDE Interrogator",0,"mydomain\coduy","P0kroy$")
$uncServer = "\\10.10.0.10\"
$uncFullPath = "\\10.13.0.10\DeploymentShare\Applications\JDE Interrogator"
$username = "coduy"
$password = "password"
$Foldername="C:\Program Files\Interrogator"
net use $uncServer $password /USER:$username
try
{
mkdir C:\'Program Files'\Interrogator
Copy-Item -Path \\10.10.0.10\DeploymentShare\Applications\JDE-Interrogator\* -Destination $Foldername
}
finally {
net use $uncServer /delete
}
該文件是否已經存在於目的地,如果它是隻讀的,您是否有權修改該文件? – TheMadTechnician 2014-09-30 17:28:09
這是一個權限問題,更適合[SuperUser](http://superuser.com)或[服務器故障](http://serverfault.com)。 – Raf 2014-10-01 08:33:28
如何將它移動到其他頁面? – Okrx 2014-10-01 08:44:42