我正在尝试检查作为 NT 服务运行应用程序使用 PowerShell 在组件服务中为 COM+ 中的应用程序创建框。
有人知道 $component.Value(s) 可以做到这一点吗?
任何帮助将不胜感激!
答案1
就我而言:
$comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog
$comAdmin.ShutdownApplication("MqsAgent2")
$applications = $comAdmin.GetCollection("Applications")
$applications.Populate()
foreach ($application in $applications)
{
if ($application.Name -eq "MqsAgent2")
{
$application.Value("Changeable") = $true
}
}
$applications.SaveChanges() | Out-Null
$comAdmin.StartApplication("MqsAgent2")
**$comAdmin.CreateServiceForApplication("MqsAgent2","MqsAgent2","SERVICE_AUTO_START","SERVICE_ERROR_CRITICAL","",".\MqsAgentUser","P@ssw0rd",$False)**
$comAdmin.ShutdownApplication("MqsAgent2")
$applications = $comAdmin.GetCollection("Applications")
$applications.Populate()
foreach ($application in $applications)
{
if ($application.Name -eq "MqsAgent2")
{
$application.Value("Activation") = "1"
$application.Value("Identity") = ".\MqsAgentUser"
$application.Value("Password") = "P@ssw0rd"
}
}
$applications.SaveChanges() | Out-Null
希望能帮助到你)