开发者

Powershell, remote script access denied to network resources

开发者 https://www.devze.com 2023-04-13 08:15 出处:网络
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:

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 开发者_JAVA技巧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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号