我在运行我创建的用于将系统附加到控制台的自定义 PS 脚本时遇到了问题。
当我在 DPM 管理外壳中以交互方式运行 PS 脚本时,它能够正常工作。
我一直在 cmd 中测试该脚本。
Connect-DPMServer : Unable to connect to contoso-dpm01.fake.com. (ID:948)
Verify that the DPM service is running on this computer.
At C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\Attach-ProductionS
erver.ps1:49 char:31
该脚本很简单,它将计算机名称传递给 Attach-ProductionServer.ps1
感谢阅读。-保罗
这是我的脚本:
param([string] $DPMServerName, [string] $PSFileList)
if(!$args[0])
{
if(!$DPMServerName)
{
$DPMServerName = "contoso-dpm01.fake.com"
}
}
if(!$PSFileList)
{
$PSFileList = "\\Share1\DPM_LOGS.txt"
}
$UserName = "`$DomAdmin"
$pwd = "Password"
$Domain = "fake.com"
$installPath = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft Data Protection Manager\Setup" "UIInstallPath").UIInstallPath
$dpmModuleFullPath = $installPath + "Modules\DataProtectionManager\DataProtectionManager.psd1"
Import-Module $dpmModuleFullPath
type $PSFileList | foreach -process {
if (!$_.Equals(""))
{
.\Attach-ProductionServer.ps1 -DPMServerName $DPMServerName -PSName $_ -Username $UserName - Password $pwd -domain $Domain
}
}
# Get the date
$DateStamp = get-date -uformat "%m-%d-%y@%H-%M"
rename-item $PSFileList $DateStamp