Posted On July 13, 2019

PowerShell: Script to Stop, Start, Disable, and Enable Exchange Server

kimconnect 0 comments
blog.KimConnect.com >> Codes , Windows >> PowerShell: Script to Stop, Start, Disable, and Enable Exchange Server
<#
This script contains a set of functions to administer Exchange 2010, 2013, 2016, and 3000. However, it will not control Lotus Domino, Open Xchange, or Zimbra.

Usage: paste this into an elevated PowerShell session of an Exchange server. Then, run one of these commands:
- stopExchange
- startExchange
- disableExchange
- enableExchange
#>

$exchangeServices=Get-Service | Where-Object {$_.DisplayName –like "Microsoft Exchange *"};

function stopExchange{
net stop msexchangeadtopology /y
net stop msexchangefba /y
net stop msftesql-exchange /y
net stop msexchangeis /y
net stop msexchangesa /y
net stop iisadmin /y
net stop w3svc /y
$exchangeServices | Stop-Service -Force;
}

function startExchange{
net start "World Wide Web Publishing Service"
net start "Microsoft Exchange Information Store"
net start "Microsoft Exchange Unified Messaging"
net start "Microsoft Exchange Transport Log Search"
net start "Microsoft Exchange Transport"
net start "Microsoft Exchange Throttling"
net start "Microsoft Exchange Service Host"
net start "Microsoft Exchange RPC Client Access"
net start "Microsoft Exchange Replication"
net start "Microsoft Exchange Mailbox Replication"
net start "Microsoft Exchange Mailbox Assistants"
net start "Microsoft Exchange EdgeSync"
net start "Microsoft Exchange Anti-spam Update"
$exchangeServices | Start-Service;
}

function disableExchange{
stopExchange;
$exchangeServices | Set-Service –StartupType Disable;
$exchangeServices | Get-Service | select -property name,starttype
}

function enableExchange{
$exchangeServices | Set-Service –StartupType Automatic;
$exchangeServices | Get-Service | select -property name,starttype
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

JavaScript: Show the Local Weather

Demo: https://blog.kimconnect.com/wp-content/projects/showLocalWeather.html HTML Code: <html><body><h3 class="text-center">A Free Code Camp JavaScript Intermediate Level Project</h3><div class="container"><div class="text-center">…

PowerShell: Convert String to Command

# Method 1 $command =@"ping google.com"@$scriptBlock = [Scriptblock]::Create($command)Invoke-Command -ComputerName localhost -ScriptBlock $scriptBlock# Method 2$xVariable="K1"$yVariable="ping"$commandString=$yVariable+" "+$xVariablefunction…

ADFS: Adding a Relying Party Trust

The following instructions assume the task of creating a authentication endpoint to allow external users…