这个Powershell代码将启动/关闭COM +,我在想。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Hexagon | Home</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css?family=Arima+Madurai" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Bungee+Shade" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<header>
<div class="container-fluid">
<div class="row">
<div class="col-md-6 red-500">
</div>
<div class="col-md-6 green-500">
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-6 hex-cont">
<div class="hexagon">
<i class="fa fa-handshake-o logo" aria-hidden="true" style="font-size:7em;"></i>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 white">
<h1 class="text-center wit">Friend Zone</h1>
<h3 class="text-center wit">Mediation Service</h3>
</div>
</div>
</div>
</header>
Powershell不会抱怨。但是,如何查看应用程序是否已关闭/启动?我可以在“组件服务”窗口中看到它,但不知道如何判断它是否正在运行。
有一种简单的方法可以使用Powershell告诉我这个吗? 我发现有一个名为“IsPaused”的COMAdminCatalogObject返回true或false。但是,我不知道如何引用它。我发现的所有示例和解决方案都是组件服务中所有应用程序的多行循环。 我在想这样的事情会起作用:
body{
font-family: 'Arima Madurai', cursive;
}
.hexagon {
position: relative;
width: 200px;
height: 115.47px;
background-color: #64C7CC;
margin: 57.74px 0;
display:block;
}
.hexagon:before,
.hexagon:after {
content: "";
position: absolute;
width: 0;
border-left: 100px solid transparent;
border-right: 100px solid transparent;
}
.hexagon:before {
bottom: 100%;
border-bottom: 57.74px solid #64C7CC;
}
.hexagon:after {
top: 100%;
margin-left:-83%;
width: 0;
border-top: 57.74px solid #64C7CC;
}
.red-500{
background:#FF4500;
height:250px;
z-index:0;
display:block;
}
.green-500{
background:#4CA64C;
height:250px;
z-index:-5;
}
答案 0 :(得分:1)
COM列表
$comAdmin = New-Object -com ("COMAdmin.COMAdminCatalog.1")
$applications = $comAdmin.GetCollection("Applications")
$applications.Populate()
foreach ($application in $applications)
{
$components = $applications.GetCollection("Components",$application.key)
$components.Populate()
foreach ($component in $components)
{
$dllName = $component.Value("DLL")
$componentName = $component.Name
"Component Name:$componentName"
"DllName: $dllName`n"
}
}
您可以开始或停止使用:
$comAdmin.StartApplication("appName")
$comAdmin.ShutdownApplication("appName")
安装:
请参阅:Microsoft Link
$comAdmin.InstallApplication("fileName")
关闭所有COM :
$sb = {
$admin = New-Object -Com ("COMAdmin.COMAdminCatalog")
$apps = $admin.GetCollection("Applications")
$apps.Populate()
$apps | % {
$component = $apps.GetCollection("Components", $_.Key)
$component.Populate()
$component | % {
$admin.ShutdownApplication("$_.Name")
}
}
}
$servers | % {Invoke-Command -ComputerName $_ -ScriptBlock $sb}
希望它有所帮助。
答案 1 :(得分:1)
有:
$catalog = New-Object -ComObject "COMAdmin.COMAdminCatalog"
$appCollection = $catalog.GetCollection("Applications")
$appCollection.Populate()
$appList = @{}
$appCollection | ForEach-Object {
$appList.Add($_.Value("ID"), $_.Name)
}
$appInstances = $catalog.GetCollection("ApplicationInstances")
$appInstances.Populate()
$appInstanceList = @{}
$appInstances | ForEach-Object {
$appValue = $_.Value("Application")
$appInstanceList.Add($appValue, $appList[$appValue])
}
$appList.Keys | ForEach-Object {
New-Object PSObject -Property @{
"Name" = $appList[$_]
"ID" = $_
"Running" = $appInstanceList.ContainsKey($_)
}
}