从另一个脚本调用时远程脚本失败

发布于 2024-12-10 11:10:46 字数 359 浏览 1 评论 0原文

我创建的脚本有一个奇怪的问题。

它在几个不同的远程主机上执行各种操作。当直接从命令行调用时,它可以完美运行。但是,当从另一个脚本调用该脚本(使用“&”或“.”运算符)时,某些远程计算机会失败。

一些远程主机加入到与我运行的计算机相同的域中,并且这些主机出现故障。一些远程主机是非域链接的计算机,并且为它们明确提供了凭据 - 在这种情况下,无论是直接调用还是从脚本调用,它们都可以工作。

错误是:

使用 Kerberos 身份验证时发生以下错误:有 当前没有可用于服务登录请求的登录服务器。

直接调用脚本或从不同的脚本调用有什么区别?我该如何解决这个问题?

I have an odd issue with a script I've created.

It executes various actions on a few different remote hosts. When called directly from the command line it works perfectly. However when the script is invoked from another script (using '&' or '.' operators), it fails for some of the remote machines.

Some of the remote hosts are joined to the same domain as the machine I'm running from, and these hosts fail. Some of the remote hosts are non-domain linked machines and credentials are provided explicitly for them - and in that case they work whether called directly or from a script.

The error is:

The following error occured while using Kerberos authentication: There
are currently no logon servers available to service the logon request.

What is the difference between calling the script directly, or from a different script? And how can I work around the issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我们的影子 2024-12-17 11:10:46

看来是我的错。

结果我使用了一个名为 $credentials 的变量来为 Invoke-Command 调用提供显式凭据。如果不需要明确的凭据,我会将其保留为空。

不幸的是,我的调用脚本还创建了一个名为 $credentials 的变量来执行它正在执行的一些操作,并且被调用的脚本从其父范围继承了该值 - 但新的凭据对于域计算机来说都是错误的,因此登录失败了。

我的 powershell 黑客攻击很糟糕,感谢大家的帮助!

Looks like it was my fault.

Turns out I was using a variable called $credentials to supply the explicit credentials to the Invoke-Command call. And I was leaving it as null if no explicit credentials were required.

Unfortunately my calling script was also creating a variable called $credentials to do some of the things it was doing, and the called script had inherited the value from its parent scope - but the new credentials were all wrong for the domain machines and hence the login was failing.

Bad powershell hacking on my part, thanks all for your help!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文