我被USMT迁移卡住了。下面是我的代码:
$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 最后一行有问题-我得到错误:
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,一切工作起来都很有魅力……
有人能帮我一下吗?非常感谢。
发布于 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" },这将会起作用。
https://stackoverflow.com/questions/28067207
复制相似问题