【发布时间】:2015-07-23 05:13:58
【问题描述】:
我正在运行一个需要连接到 DPM 服务器的 PowerShell 脚本。
当我从 DPM 管理外壳运行 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
Get-DPMProtectionGroup 等其他 DPM cmdlet 也是如此。
我在 Windows Server 2008 R2 上运行 Powershell 2.0 版。
这种特殊行为的原因是什么?我该如何解决?
编辑
我做了一些观察。我的脚本有两部分:一个包装脚本和一个由包装脚本作为独立作业调用的帮助脚本。
所有 DPM 命令都在包装脚本中标识,但在作为作业运行时在帮助脚本中没有标识。
任何解释为什么会这样以及解决相同问题的任何建议?
【问题讨论】:
-
您可以尝试通过以下方式列出您已安装的命令:
Get-command在不工作的 shell 中 -
我会在你的帮助脚本中打印出
Get-Command并输出带有$PSVersionTable的Powershell 版本以缩小范围
标签: powershell dpm