Powershell, remote script access denied to network resources

核能气质少年 提交于 2019-11-27 07:55:05

问题


I am trying to execute powershell script remotely using invoke-command. The script relies on a configuration file which is available over the local network. The script is called in a following way:

Invoke-Command -ComputerName 192.168.137.181 -FilePath c:\scripts\script.ps1 -ArgumentList \\192.168.137.1\share\config.xml

The configuration as you can see is an xml file and it's loaded using:

$xml = New-Object XML
$xml.Load(args[0])

When the script is called locally on the machine then it runs witout any problems and reads the configuration file. However when I run it from different machine using invoke command I get

"Access to the path '\\192.168.137.1\share\config.xml' is denied"

exception, which is thrown when executing Load method.

The file is accessible to everyone with read and write permissions. Both, machine on which the scrip should be run (.181) and the machine on which it is run physically have the same credentials, thus I do not pass them in invoke-command cmdlet. The share machine (.1) has different credential, but this was never an issue when calling the script locally from .181.

Can you please point me in the right direction? I stuck on this step and can't find solution by myself. I tried downloading the xml string using WebClient#DownloadString method and passing credentials for the share machine but it did not help.

Thanks in advance


回答1:


It is probably a double hop issue. You have to use CredSSP to delegate your credentials to the remote computer.

Try the solution mentioned here: http://blogs.msdn.com/b/clustering/archive/2009/06/25/9803001.aspx



来源:https://stackoverflow.com/questions/7794206/powershell-remote-script-access-denied-to-network-resources

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!