<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>restart Exchange services Archives - the Sysadmin Channel</title>
	<atom:link href="https://thesysadminchannel.com/tag/restart-exchange-services/feed/" rel="self" type="application/rss+xml" />
	<link>https://thesysadminchannel.com/tag/restart-exchange-services/</link>
	<description>Documenting My Life as a System Administrator</description>
	<lastBuildDate>Sat, 25 Jun 2022 03:31:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
<site xmlns="com-wordpress:feed-additions:1">144174110</site>	<item>
		<title>Restart Exchange Services with PowerShell</title>
		<link>https://thesysadminchannel.com/restart-exchange-services-with-powershell/</link>
					<comments>https://thesysadminchannel.com/restart-exchange-services-with-powershell/#respond</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Sat, 25 Jun 2022 03:31:55 +0000</pubDate>
				<category><![CDATA[Exchange Server]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[restart Exchange services]]></category>
		<category><![CDATA[Restart Exchange Services with PowerShell]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=4171</guid>

					<description><![CDATA[<p>If you&#8217;re hosting Microsoft Exchange server on-premises, you&#8217;ve probably realized that it is pretty critical to ensure those services are up and running. In the event that some services are not running, it&#8217;s always good to know how to restart&#8230; <a href="https://thesysadminchannel.com/restart-exchange-services-with-powershell/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/restart-exchange-services-with-powershell/">Restart Exchange Services with PowerShell</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If you&#8217;re hosting Microsoft Exchange server on-premises, you&#8217;ve probably realized that it is pretty critical to ensure those services are up and running.  In the event that some services are not running, it&#8217;s always good to know how to <strong>restart Exchange services with Powershell</strong>.<br />
&nsbp;</p>
<p>Knowing how to restart Exchange services can also be of use when you want to automate the starting of services when it goes down.  The monitoring system you have in place should be able to detect that, and hopefully remediate it automatically so you&#8217;re not wasting cycles using manual intervention.</p>
<div id="tableofcontents">
<h2>Table Of Contents</h2>
<ul>
<li><a href="#requirements">Requirements</a></li>
<li><a href="#getservicemethods">Get Exchange Service Details</a></li>
<ul>
<li><a href="#getservice">Get Exchange Service Details using Get-Service</a></li>
<li><a href="#getciminstance">Get Exchange Service Details using Get-CimInstance</a></li>
</ul>
<li><a href="#restartexchange">Restart Exchange Services with PowerShell</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ul>
</div>
<div id="requirements" style="scroll-margin-top: 15px;"></div>
<h2>Requirements</h2>
<p>In order to get started, we will certainly need to know a few things before hand.  One of those things is obviously the name of the Server(s) that are running Exchange.  Aside from that, having administrator rights on the box would be great.</p>
<div id="getservicemethods" style="scroll-margin-top: 15px;"></div>
<h2>Get Exchange Service Details</h2>
<p>Before we touch base on restarting the services, we&#8217;ll want to know which services are going to be in scope so we&#8217;re not inadvertently restarting something that doesn&#8217;t need to be restarted.  We have 2 options to get the information we need through Powershell.  The first, we can use the <code>Get-Service</code> along with <code>Invoke-Command</code> to query the services.  Second, we can use the <code>Get-CimInstance</code> along with the ComputerName parameter to query the machine for these services.<br />
&nbsp;</p>
<p>From a reporting standpoint, I personally like <code>Get-CimInstance</code> because it offers a bit more detail than the alternative.  However, as far as actually restarting the services, we&#8217;ll stick to <code>Get-Service</code> and pipe it to <code>Restart-Service</code> to get the job done.<br />
&nbsp;</p>
<div id="getservice" style="scroll-margin-top: 15px;"></div>
<h4>Get Exchange Service Details using Get-Service</h4>
<p>As mentioned, we can use <code>Get-Service</code> to get the information we need.  Let&#8217;s show a little snippet of how to do that.</p>
<pre class="brush: powershell; title: ; notranslate">
Invoke-Command -ComputerName PAC-EXCH01 -ScriptBlock `
{Get-Service -Name *msexch* | select Name, DisplayName, StartType, Status}
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2022/06/Get-Exchange-Services.png" target="_blank" rel="noopener"><img fetchpriority="high" decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2022/06/Get-Exchange-Services.png" alt="Get-Exchange Services" width="851" height="359" class="aligncenter size-full wp-image-4271" srcset="https://thesysadminchannel.com/wp-content/uploads/2022/06/Get-Exchange-Services.png?v=1656120492 851w, https://thesysadminchannel.com/wp-content/uploads/2022/06/Get-Exchange-Services-768x324.png?v=1656120492 768w" sizes="(max-width: 851px) 100vw, 851px" /></a><br />
&nbsp;</p>
<div id="getciminstance" style="scroll-margin-top: 15px;"></div>
<h4>Get Exchange Service Details using Get-CimInstance</h4>
<p>Let&#8217;s cover the alternative for getting the exchange services using CimInstance.</p>
<pre class="brush: powershell; title: ; notranslate">
Get-CimInstance -Class Win32_Service -ComputerName PAC-EXCH01 -Filter &quot;Name like '%MSEXCH%'&quot; | `
select Name, DisplayName, StartMode, StartName, State
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2022/06/GetExchange-Services-CimInstance.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2022/06/GetExchange-Services-CimInstance.png" alt="Get Exchange Services CimInstance" width="970" height="438" class="aligncenter size-full wp-image-4275" srcset="https://thesysadminchannel.com/wp-content/uploads/2022/06/GetExchange-Services-CimInstance.png?v=1656121496 970w, https://thesysadminchannel.com/wp-content/uploads/2022/06/GetExchange-Services-CimInstance-768x347.png?v=1656121496 768w" sizes="(max-width: 970px) 100vw, 970px" /></a></p>
<p>&nbsp;</p>
<div id="restartexchange" style="scroll-margin-top: 15px;"></div>
<h2>Restart Exchange Services with PowerShell</h2>
<p>Now that we know how to query the services, we can use Powershell to see which services are Exchange related as well as which ones are supposed to be running using Where-Object, a fundamental Powershell function.</p>
<pre class="brush: powershell; title: ; notranslate">
Invoke-Command -ComputerName PAC-EXCH01 -ScriptBlock `
{Get-Service -Name *msexch* | Where-Object {$_.StartType -match 'Automatic' -and $_.Status -ne 'Running'} | select Name, DisplayName, StartType, Status}
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2022/06/Get-Exchange-Services-Not-Running.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2022/06/Get-Exchange-Services-Not-Running.png" alt="Get-Exchange Services Not Running" width="1099" height="264" class="aligncenter size-full wp-image-4277" srcset="https://thesysadminchannel.com/wp-content/uploads/2022/06/Get-Exchange-Services-Not-Running.png?v=1656122585 1099w, https://thesysadminchannel.com/wp-content/uploads/2022/06/Get-Exchange-Services-Not-Running-1024x246.png?v=1656122585 1024w, https://thesysadminchannel.com/wp-content/uploads/2022/06/Get-Exchange-Services-Not-Running-768x184.png?v=1656122585 768w" sizes="(max-width: 1099px) 100vw, 1099px" /></a><br />
&nbsp;</p>
<p>From here, we can simply pipe the results to Restart-Service.  Here&#8217;s how to do that.</p>
<pre class="brush: powershell; title: ; notranslate">
Invoke-Command -ComputerName PAC-EXCH01 -ScriptBlock `
{Get-Service -Name *msexch* | Where-Object {$_.StartType -match 'Automatic' -and $_.Status -ne 'Running'} | Restart-Service }
</pre>
<div id="conclusion" style="scroll-margin-top: 15px;"></div>
<h2>Conclusion</h2>
<p>Hopefully we were able to showcase how to restart Exchange services with PowerShell and allow you to either setup monitoring using PS, or to simply restart the service if it just happens to not be running.<br />
&nbsp;</p>
<p>If you liked this article, be sure to check out <a href="https://thesysadminchannel.com/get-exchange-schema-version-using-powershell/" rel="noopener" target="_blank">Get Exchange Schema Version Using Powershell</a>.  Also, be sure to take a look at our <a href="https://www.youtube.com/c/theSysadminChannel" rel="noopener" target="_blank">YouTube Channel</a> for more sysadmin videos.</p>
<p>The post <a href="https://thesysadminchannel.com/restart-exchange-services-with-powershell/">Restart Exchange Services with PowerShell</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/restart-exchange-services-with-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4171</post-id>	</item>
	</channel>
</rss>
