首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Powershell - usmt loadstate.exe - CommandNotFoundException

Powershell - usmt loadstate.exe - CommandNotFoundException
EN

Stack Overflow用户
提问于 2015-01-21 20:24:54
回答 1查看 1.4K关注 0票数 0

我被USMT迁移卡住了。下面是我的代码:

代码语言:javascript
复制
$scriptA = "\\PL-HVEZDAP\backup\USMTBin\scanstate.exe \\PL-HVEZDAP\backup /ue:* /ui:$name /o /i:'\\PL-HVEZDAP\backup\USMTBin\miguser.xml' /i:'\\PL-HVEZDAP\backup\USMTBin\migapp.xml' /c"
$scriptB = "\\PL-HVEZDAP\backup\USMTBin\loadstate.exe \\PL-HVEZDAP\backup /ue:* /ui:$name /i:'\\PL-HVEZDAP\backup\USMTBin\miguser.xml' /i:'\\PL-HVEZDAP\backup\USMTBin\migapp.xml' /c"
$scriptA = [scriptblock]::Create($scriptA)
$scriptB = [scriptblock]::Create($scriptB)
Invoke-Command -ComputerName $computer -scriptblock $scriptA
Invoke-Command -ComputerName $remcomputer -scriptblock $scriptB 

最后一行有问题-我得到错误:

代码语言:javascript
复制
The term '\\PL-HVEZDAP\backup\USMTBin\loadstate.exe' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
 again.
    + CategoryInfo          : ObjectNotFound: (\\PL-HVEZDAP\ba...n\loadstate.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

但是如果我运行$scriptb = get-process,一切工作起来都很有魅力……

有人能帮我一下吗?非常感谢。

EN

回答 1

Stack Overflow用户

发布于 2015-01-21 22:35:43

看起来像是kerberos的双跳问题。一旦使用Invoke-Command连接到远程计算机,就不能再使用任何隐式使用身份验证的命令(包括cmdlet、可执行文件和连接到文件共享)。

这与Kerberos的设计方式有关。您可以在Invoke-Command中使用另一种称为CredSSP的身份验证来委派凭证,但这需要在两端都进行一些设置。

通常,重新思考这些片段存储和/或执行的位置会更容易。

由于您大量使用文件共享,因此可以考虑不对远程计算机使用Invoke-Command,而是在目标计算机上本地执行备份脚本。

要做到这一点,同时仍然能够集中存储脚本,一种方法是在运行此脚本的目标计算机上创建一个计划任务。如果你在一个域中,它甚至可以通过GPO推送出来。

然后,您可以在希望运行该代码时启动该任务。

您甚至可以使用Invoke-Command -ComputerName $remcomputer -ScriptBlock { schtasks.exe /Run /TN "My Task" },这将会起作用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28067207

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档