Skip to content

Instantly share code, notes, and snippets.

@bill-long
Last active January 2, 2024 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bill-long/8ae1d3206406116d4e8a8c3d42b9025c to your computer and use it in GitHub Desktop.
Save bill-long/8ae1d3206406116d4e8a8c3d42b9025c to your computer and use it in GitHub Desktop.
function Get-ExchangeServices {
$services = @(Get-Service MSExchange* | Where-Object { $_.StartType -eq "Automatic" })
$services += Get-Service HostControllerService
$services += Get-Service W3SVC
return $services
}
function Stop-ExchangeServices {
$servicesToStop = Get-ExchangeServices
foreach ($service in $servicesToStop) {
Stop-Service $service -Force
}
}
function Start-ExchangeServices {
$servicesToStart = Get-ExchangeServices
foreach ($service in $servicesToStart) {
Start-Service $service
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment