powershell 复制项目公共桌面访问被拒绝

powershell 复制项目公共桌面访问被拒绝

下面是我正在运行的 powershell 脚本,我是 PClist.txt 中工作站的本地管理员,并且我对共享位置有修改权限。当我运行它时,我收到以下错误:

copy-item:拒绝访问路径“\computer_name\C$\Users\Public\Desktop\Program.exe”。位于第 5 行,字符:35 + ... | foreach {copy-item -path $sourcefile -destination \$_\C$\$destina ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:PermissionDenied:(\share_name\program.exe:FileInfo) [Copy-Item],UnauthorizedAccessException + FullyQualifiedErrorId:CopyFileInfoItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.CopyItemCommand

任何有助于解决此问题的帮助都将非常有用...我确实相信问题是因为公共桌面是一个隐藏文件夹,因此访问被拒绝,但我不知道如何绕过它。

$computers = "C:\temp\PClist.txt"
$sourcefile = "\\share_name\Program.exe"
$destination = "Users\Public\Desktop"

get-content $computers | foreach {copy-item -path $sourcefile -destination \\$_\C$\$destination}

相关内容