我有这个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
的本地计算机上正确创建应用程序,但在远程计算机上运行时总是会失败。
为什么会这样?