当运行下面的代码时,我可以将任何东西放在底部的代码块中-我正在尝试复制一个文件夹以运行本地文件夹中的可执行文件,并在远程计算机的远程会话期间执行该可执行文件的安装。我收到访问被拒绝的错误。我读到,我不能使用Kerberos Delegation Cmdlet,它只适用于2012年以上的森林级别。当前站点的域功能级别为2008 R2。是否有其他方法可以在每次远程会话期间将文件复制到文本文件中指定的计算机?
提前感谢
########################################
$Cred = Get-Credential DOMAIN\USER
$Computers = Get-Content C:\tab.txt | Where-Object { $_ }
ForEach ($Computer in $Computers)
# {
# if (Test-Connection -ComputerName $Computer -BufferSize 16 -Count 1 `
-Quiet)
{
# Creates a new remote PowerShell Session and script block - enter
the code you want to execute remotely from this block
$Session = New-PSSession $computer -Credential $cred
Invoke-Command -Session $Session -ScriptBlock {
Copy-Item -Path "\\print-server\pcclient\win\*" -Destination
"c:\pcclient" -Force -Recurse -Verbose
# Start-Sleep -s 10
# Start-Process "\\Print-Server\PCClient\win\client-local-install.exe" -ArgumentList "/SILENT"
}
}
Remove-PSSession -Session $Session }
发布于 2018-01-06 01:08:49
这是因为您在一台远程计算机上,试图访问另一个网络资源。当您在PowerShell中连接到远程计算机时,您实际上只对该计算机进行了连接/身份验证,它不能访问您的凭据来访问网络共享,因此到网络共享的连接将被视为未经身份验证,从而导致失败。
本文https://blogs.technet.microsoft.com/heyscriptingguy/2012/11/14/enable-powershell-second-hop-functionality-with-credssp/很好地介绍了它,本质上是您将需要在本地运行它(以允许您的机器传递凭据):
Enable-WSManCredSSP -Role Client -DelegateComputer * -Force在服务器上运行(以允许服务器接受这些凭据):
Enable-WSManCredSSP -Role Server –Force并将您的New-PSSession命令更新为:
$Session = New-PSSession $computer -Credential $cred -Authentication CredSSP如果您愿意,您可以只与特定的计算机共享凭据,或者使用*.yourdomain.lan或任何其他方式与域的子集共享凭据。如果您连接到多台计算机,则使用-DelegateComputer *会更容易。
https://stackoverflow.com/questions/48116401
复制相似问题