jhorsman
10/22/2013 - 2:10 PM

SDL Quatron services restart, start and stop with PowerShell

SDL Quatron services restart, start and stop with PowerShell

Write-Host "Stopping all SQL Quatron services"
foreach ($svc in Get-Service)
{
    if($svc.displayname.StartsWith("SDL Quatron") -and ($svc.Status -ne "Stopped")) 
    {
        Write-Host " "$svc.DisplayName
        Stop-Service $svc.name -Force
    }
}

foreach ($svc in Get-Service)
{
    if($svc.displayname.StartsWith("SDL Quatron")) 
    {
        Get-Service $svc.name
    }
}
	
Write-Host
Write-Host "Stopping IIS"
iisreset -stop

Write-Host
pause
Write-Host "Starting all SDL Quatron services"
foreach ($svc in Get-Service)
{
    if($svc.displayname.StartsWith("SDL Quatron") -and ($svc.Status -ne "Running"))     
    {
        Write-Host " "$svc.DisplayName
        Start-Service $svc.name
    }
}

foreach ($svc in Get-Service)
{   
    if($svc.displayname.StartsWith("SDL Quatron")) 
    {
        Get-Service $svc.name
    }
}

Write-Host
Write-Host "Restarting IIS"
iisreset

Write-Host
pause
Write-Host "Restarting running SDL Quatron Services"

foreach ($svc in Get-Service)
{   
    if($svc.displayname.StartsWith("SDL Quatron")) 
	{
		if($svc.Status -eq "Running")
		{
			Write-Host " restarting"$svc.DisplayName
			Restart-Service $svc.name -Force
		} else {
			Write-Host " ignoring"$svc.DisplayName", it is"$svc.Status
		}
    }
}

foreach ($svc in Get-Service)
{
    if($svc.displayname.StartsWith("SDL Quatron")) 
    {
        Get-Service $svc.name
    }
}

Write-Host
Write-Host "Restarting IIS"
iisreset

Write-Host
pause