powershell 用于重新启动SDL Tridion Docs内容管理器服务的脚本。这包括Windows服务,组件服务和IIS应用程序池。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 用于重新启动SDL Tridion Docs内容管理器服务的脚本。这包括Windows服务,组件服务和IIS应用程序池。相关的知识,希望对你有一定的参考价值。
<#
.SYNOPSIS
Restarts Docs Content Manager services
.EXAMPLE
Restart-Docs
Restart-Docs -WindowsServices
Restart-Docs -ComponentServices
Restart-Docs -ApplicationPools
Restart-Docs -ComponentServices -ApplicationPools
.NOTES
Author: Jan Horsman
#>
#Requires -RunAsAdministrator
[CmdletBinding()]
Param(
[parameter(Mandatory=$false, HelpMessage="Restart Windows services")]
[switch]$WindowsServices,
[parameter(Mandatory=$false, HelpMessage="Restart component services")]
[switch]$ComponentServices,
[parameter(Mandatory=$false, HelpMessage="Restart IIS application pools")]
[switch]$ApplicationPools)
$ErrorActionPreference = "Stop"
if($WindowsServices -ne $true -and $ComponentServices -ne $true -and $ApplicationPools -ne $true)
{
#default to restarting everything
$WindowsServices = $true
$ComponentServices = $true
$ApplicationPools = $true
}
if($WindowsServices)
{
Write-Host "Restarting Trisoft services"
$services = Get-Service | Where { $_.DisplayName.StartsWith("Trisoft") }
if($services -eq $null)
{
Write-Warning "Could not find Trisoft services"
} else
{
foreach ($svc in $services)
{
if($svc.Status -eq "Running")
{
Write-Host (" restarting {0} " -f $svc.DisplayName)
Restart-Service $svc.name -Force
} else {
Write-Host (" ignoring {0}, it is {1}" -f $svc.DisplayName, $svc.Status)
}
}
}
}
if($ComponentServices)
{
Write-Host "Restarting component services"
$comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog
$apps = $comAdmin.GetCollection("Applications")
$apps.Populate();
# restart only Trisoft-InfoShare-Author because the other component services are libraries
$apps = $apps | Where-Object { $_.Name.Equals("Trisoft-InfoShare-Author") }
if($apps -eq $null)
{
Write-Warning "Could not find Trisoft-InfoShare-Author component service"
} else
{
foreach ($app in $apps)
{
$comAdmin.ShutdownApplication($app.Name)
Write-Host " Stoped " $app.Name
$comAdmin.StartApplication($app.Name)
Write-Host " Started" $app.Name
}
}
}
if($ApplicationPools)
{
Write-Host "Restarting application pools"
Import-Module "IISAdministration"
$appPools = Get-IISAppPool | Where-Object { $_.Name.StartsWith("Trisoft") }
if($appPools -eq $null) {
Write-Warning "Could not find Trisoft app pools"
} else
{
foreach ($pool in $appPools)
{
if($pool.State -ne "Started")
{
Write-Host " ignoring "$pool.Name", it is"$pool.Status
} else {
$result = $pool.Recycle()
Restart-WebAppPool $pool.Name
if($result -eq "Started")
{
Write-Host " Recycled " $pool.Name
} else
{
Write-Warning ("Unexpected result while recycling app pool {0}: {1}" -f $pool.Name, $result)
}
}
}
}
}
以上是关于powershell 用于重新启动SDL Tridion Docs内容管理器服务的脚本。这包括Windows服务,组件服务和IIS应用程序池。的主要内容,如果未能解决你的问题,请参考以下文章
powershell SDL Quatron服务使用PowerShell重新启动,启动和停止
powershell 脚本启动SDL Web 8.5微服务
powershell 连接到SDL Cloud中的SDL Web 8
powershell 使用PowerShell将SDL Web组件与模式同步
powershell 使用PowerShell将SDL Web组件与模式同步
powershell 使用PowerShell将SDL Web组件与模式同步