为什么要设置' QueuingEnabled' PowerShell远程COM +应用程序导致保存失败?

时间:2014-04-23 11:10:16

标签: powershell com msmq com+ comadmin

我有这个powershell脚本,它在远程机器上创建COM +应用程序:

$credentials = Get-Credential -Message "Test" -User "DOMAIN\User"
$roleRM = new-pssession -computername MACHINE -credential $credentials

Invoke-Command -Session $roleRM -scriptblock `
{
$comAdmin = New-Object -ComObject ("COMAdmin.COMAdminCatalog.1")   
$comApplicationCollection = $comAdmin.GetCollection("Applications")
$comApplicationCollection.Populate()
$comApplication = $comApplicationCollection.Add()
$comApplication.Value("Name") = "Server"
$comApplication.Value("ApplicationAccessChecksEnabled") = 0
$comApplication.Value("AccessChecksLevel") = (0)
$comApplication.Value("Authentication") = (1)
$comApplication.Value("Identity") = "DOMAIN\User"
$comApplication.Value("Password") = "password"
$comApplication.Value("QueuingEnabled") = 1
$comApplication.Value("QueueListenerEnabled") = 1
$comApplicationCollection.SaveChanges()
}

但是当我尝试运行它时失败并出现此错误:

Exception calling "SaveChanges" with "0" argument(s): "An operations error occurred. " + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ComMethodTargetInvocation + PSComputerName : MACHINE

如果我排除这一行:

$comApplication.Value("QueuingEnabled") = 1

然后它正确保存并创建应用程序。如果我在本地运行此脚本,那么它会在QueuingEnabled=1的本地计算机上正确创建应用程序,但在远程计算机上运行时总是会失败。

为什么会这样?

1 个答案:

答案 0 :(得分:0)

尝试设置"身份验证"到4或6,看看是否有任何改变。请参阅this