我正在运行一个需要连接到 DPM 服务器的 PowerShell 脚本。
当我从 DPM Manangement Shell 运行Connect-DPMServer <DPM Server Name>
cmdlet 时,命令成功并且我能够连接到服务器。
但是,当我在脚本中包含相同的命令并通过 DPM 命令行管理程序调用脚本时,会出现以下错误:
The term 'Connect-DPMServer' 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: (Connect-DPMServer:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
其他 DPM cmdlet(如Get-DPMProtectionGroup
.
我在 Windows Server 2008 R2 上运行 Powershell 2.0 版。
这种特殊行为的原因是什么,我该如何解决?
编辑
我做了一些观察。我的脚本有两部分:一个包装器脚本和一个由包装器脚本作为独立作业调用的帮助器脚本。
所有 DPM 命令都在包装脚本中标识,但当它作为作业运行时,它们不会在帮助脚本中标识。
任何解释为什么会这样以及解决相同问题的任何建议?