<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Bhargav's IT Playground</title>
	
	<link>http://www.bhargavs.com</link>
	<description>Passion for Technology. Power of Messaging.</description>
	<lastBuildDate>Wed, 01 Sep 2010 20:11:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/bhargavs" /><feedburner:info uri="bhargavs" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Microsoft Exchange Online–User Group Meeting September 09</title>
		<link>http://feedproxy.google.com/~r/bhargavs/~3/9emtXJ7p9mY/</link>
		<comments>http://www.bhargavs.com/index.php/2010/08/31/microsoft-exchange-online%e2%80%93user-group-meeting-september-09/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 05:44:51 +0000</pubDate>
		<dc:creator>Bhargav</dc:creator>
		
		<guid isPermaLink="false">http://www.bhargavs.com/index.php/2010/08/31/microsoft-exchange-online%e2%80%93user-group-meeting-september-09/</guid>
		<description><![CDATA[Philadelphia Area Exchange Server User Group is hosting a meeting on September 9, dedicated to Microsoft Exchange Online!
Many have been asking what does Microsoft Online offer? What does it mean? How do I upgrade my skills for new type of computing that is gaining popularity rapidly.
Well, we are answering the questions by dedicating this meeting [...]]]></description>
			<content:encoded><![CDATA[<p>Philadelphia Area Exchange Server User Group is hosting a meeting on September 9, dedicated to Microsoft Exchange Online!</p>
<p>Many have been asking what does Microsoft Online offer? What does it mean? How do I upgrade my skills for new type of computing that is gaining popularity rapidly.</p>
<p>Well, we are answering the questions by dedicating this meeting specifically to Microsoft Exchange Online offering. We will discuss details, answer questions and demo BPOS-S deployment live!</p>
<p>While, we are deviating from our standard meeting schedule (second Tuesday of the month), we are sure you will enjoy the content being covered and greatly benefit from it.</p>
<p>We highly recommend you attend in person if possible. You can find more details and RSVP <a href="http://www.phillyexug.org/September-09-Meeting">here</a>.</p>
<p>Remote users can join using Live Meeting at URL <a href="http://bit.ly/phillyexugmonthly">http://bit.ly/phillyexugmonthly</a>. If you do not have Live Meeting client installed, you can install it from <a href="http://bit.ly/livemeetingclient">http://bit.ly/livemeetingclient</a>.</p>
<p>We look forward to your valued participation in this very exciting meeting.</p>
<p>Originally posted at http://blogs.technet.com/bshukla</p>
<div id="pfButton"><a href="http://www.bhargavs.com/index.php/2010/08/31/microsoft-exchange-online%e2%80%93user-group-meeting-september-09/?pfstyle=wp" title="Print an optimized version of this web page"><img id="printfriendly" style="border:none; padding:0;" src="http://cdn.printfriendly.com/pf-button.gif" alt="Print"/></a></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bhargavs?a=9emtXJ7p9mY:gvNlCBRRVkc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bhargavs?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bhargavs?a=9emtXJ7p9mY:gvNlCBRRVkc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/bhargavs?i=9emtXJ7p9mY:gvNlCBRRVkc:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bhargavs/~4/9emtXJ7p9mY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bhargavs.com/index.php/2010/08/31/microsoft-exchange-online%e2%80%93user-group-meeting-september-09/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bhargavs.com/index.php/2010/08/31/microsoft-exchange-online%e2%80%93user-group-meeting-september-09/</feedburner:origLink></item>
		<item>
		<title>Updated – Verify Exchange Server Schema Version</title>
		<link>http://feedproxy.google.com/~r/bhargavs/~3/6E0yH2NHTCM/</link>
		<comments>http://www.bhargavs.com/index.php/2010/08/31/updated-verify-exchange-server-schema-version/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 16:20:47 +0000</pubDate>
		<dc:creator>Bhargav</dc:creator>
				<category><![CDATA[Exchange 2010]]></category>

		<guid isPermaLink="false">http://www.bhargavs.com/index.php/2010/08/31/updated-verify-exchange-server-schema-version/</guid>
		<description><![CDATA[When you run Exchange Setup to prepare schema, usually the very next question is, how do I verify schema was updated successfully? Verifying only the values of attributes as mentioned below is not a good verification of Exchange setup completion. This article is intended to only provide reference to attributes and their values.
Since I have [...]]]></description>
			<content:encoded><![CDATA[<p>When you run Exchange Setup to prepare schema, usually the very next question is, how do I verify schema was updated successfully? Verifying only the values of attributes as mentioned below is not a good verification of Exchange setup completion. This article is intended to only provide reference to attributes and their values.</p>
<p>Since I have wrote about it previously, I don’t want to duplicate entire post here. Here’s the <a href="http://www.bhargavs.com/index.php/2009/11/20/verify-exchange-server-schema-version">link</a> to previous post which is updated to include Exchange 2010 Service Pack 1 as well!</p>
<p>Originally posted at http://blogs.technet.com/bshukla</p>
<div id="pfButton"><a href="http://www.bhargavs.com/index.php/2010/08/31/updated-verify-exchange-server-schema-version/?pfstyle=wp" title="Print an optimized version of this web page"><img id="printfriendly" style="border:none; padding:0;" src="http://cdn.printfriendly.com/pf-button.gif" alt="Print"/></a></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bhargavs?a=6E0yH2NHTCM:-n3BPOjByXQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bhargavs?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bhargavs?a=6E0yH2NHTCM:-n3BPOjByXQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/bhargavs?i=6E0yH2NHTCM:-n3BPOjByXQ:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bhargavs/~4/6E0yH2NHTCM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bhargavs.com/index.php/2010/08/31/updated-verify-exchange-server-schema-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bhargavs.com/index.php/2010/08/31/updated-verify-exchange-server-schema-version/</feedburner:origLink></item>
		<item>
		<title>Script to change Address Book Service throttling on Exchange 2010</title>
		<link>http://feedproxy.google.com/~r/bhargavs/~3/vCCUwILvwRE/</link>
		<comments>http://www.bhargavs.com/index.php/2010/08/20/script-to-change-address-book-service-throttling-on-exchange-2010/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 16:44:27 +0000</pubDate>
		<dc:creator>Bhargav</dc:creator>
				<category><![CDATA[Exchange 2010]]></category>

		<guid isPermaLink="false">http://www.bhargavs.com/index.php/2010/08/20/script-to-change-address-book-service-throttling-on-exchange-2010/</guid>
		<description><![CDATA[If you are deploying BlackBerry in Exchange 2010 environment, one of the requirements is to change throttling limits on Address Book Service from default 50 to 100,000. While I reserve my judgment to what number is right, you will have to change it to some number above 50 for sure.
If you have many CAS servers [...]]]></description>
			<content:encoded><![CDATA[<p>If you are deploying BlackBerry in Exchange 2010 environment, one of the requirements is to change throttling limits on Address Book Service from default 50 to 100,000. While I reserve my judgment to what number is right, you will have to change it to some number above 50 for sure.</p>
<p>If you have many CAS servers where you have to change this, it quickly becomes painful because you have to change config file and restart services.</p>
<p>Well, sweat no more if you are in this situation. Use my script instead.</p>
<p>You can download the script here: <a href="http://cid-14adc5cf1e0cbccf.office.live.com/self.aspx/.Public/Exchange%202010/Scripts/Set-ThrottlingLimit.ps1">Set-ThrottlingLimit.ps1</a></p>
<p>I will avoid posting entire code here but below are some examples of how you can run it:</p>
<p>The following example will query specified server for current value of MaxSessionsPerUser:</p>
<p>&nbsp;
<pre class="brush:ps">Set-ThrottlingLimit -Server Server1</pre>
<p>&nbsp;</p>
<p>The following example will set MaxSessionsPerUser to 5000 and restart services MSEXchangeRPC and MSExchangeAB without confirmation:</p>
<p>&nbsp;
<pre class="brush:ps">Set-ThrottlingLimit -Server Server1 -MaxSessionsPerUser "5000" -force $true</pre>
<p>&nbsp;</p>
<p>The following example will set MaxSessionsPerUser to 5000 and restart services MSEXchangeRPC and MSExchangeAB after confirmation from user:</p>
<p>&nbsp;
<pre class="brush:ps">Set-ThrottlingLimit -Server Server1 -MaxSessionsPerUser "5000"</pre>
<p>&nbsp;</p>
<p>Questions and Comments are always welcome.</p>
<p>Originally posted at http://blogs.technet.com/bshukla</p>
<div id="pfButton"><a href="http://www.bhargavs.com/index.php/2010/08/20/script-to-change-address-book-service-throttling-on-exchange-2010/?pfstyle=wp" title="Print an optimized version of this web page"><img id="printfriendly" style="border:none; padding:0;" src="http://cdn.printfriendly.com/pf-button.gif" alt="Print"/></a></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bhargavs?a=vCCUwILvwRE:109eCXQUdkM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bhargavs?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bhargavs?a=vCCUwILvwRE:109eCXQUdkM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/bhargavs?i=vCCUwILvwRE:109eCXQUdkM:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bhargavs/~4/vCCUwILvwRE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bhargavs.com/index.php/2010/08/20/script-to-change-address-book-service-throttling-on-exchange-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bhargavs.com/index.php/2010/08/20/script-to-change-address-book-service-throttling-on-exchange-2010/</feedburner:origLink></item>
		<item>
		<title>How to convert a word document to other formats using PowerShell</title>
		<link>http://feedproxy.google.com/~r/bhargavs/~3/_akZiYspJ_c/</link>
		<comments>http://www.bhargavs.com/index.php/2010/07/28/how-to-convert-a-word-document-to-other-formats-using-powershell/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 04:27:30 +0000</pubDate>
		<dc:creator>Bhargav</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.bhargavs.com/index.php/2010/07/28/how-to-convert-a-word-document-to-other-formats-using-powershell/</guid>
		<description><![CDATA[I recently borrowed a Sony Reader Touch Edition from someone I know to try it out. As I started using Sony’s own library manager, I quickly got bored. I then tried open source Calibre which turned out to be a lot better interface but had a major flaw when it comes to supporting Sony Reader: [...]]]></description>
			<content:encoded><![CDATA[<p>I recently borrowed a <a href="http://www.sonystyle.com/webapp/wcs/stores/servlet/ProductDisplay?catalogId=10551&amp;storeId=10151&amp;langId=-1&amp;productId=8198552921665921180">Sony Reader Touch Edition</a> from someone I know to try it out. As I started using Sony’s own library manager, I quickly got bored. I then tried open source <a href="http://calibre-ebook.com">Calibre</a> which turned out to be a lot better interface but had a major flaw when it comes to supporting Sony Reader: It didn’t support importing word documents in the library despite of Sont Reader’s capability to read it. It can however import filtered html files which work can produce. Given my lazy nature, I did not want to convert a bunch of word documents I have by hand so I set out to write a PowerShell script to do the work for me.</p>
<p>The script turned out to be much simpler than I thought. Here it is for everyone’s benefit.</p>
<pre class="brush: ps">param([string]$docpath,[string]$htmlpath = $docpath)

$srcfiles = Get-ChildItem $docPath -filter "*.doc"
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatFilteredHTML");
$word = new-object -comobject word.application
$word.Visible = $False

function saveas-filteredhtml
	{
		$opendoc = $word.documents.open($doc.FullName);
		$opendoc.saveas([ref]"$htmlpath\$doc.fullname.html", [ref]$saveFormat);
		$opendoc.close();
	}

ForEach ($doc in $srcfiles)
	{
		Write-Host "Processing :" $doc.FullName
		saveas-filteredhtml
		$doc = $null
	}

$word.quit();
</pre>
<p>Save this code to convertdoc-tohtml.ps1 and you can run it on a set of word documents regardless of doc or docx extension. Also for efficiency I am using –filter in Get-ChildItem instead of piping to where-object or using If statement in the script. Why? Because it says right in the help:</p>
<blockquote>
<p>“Filters are more efficient than other parameters, because the provider applies them when retrieving the objects, rather than having Windows PowerShell filter the objects after they are retrieved.”</p>
</blockquote>
<p>To run the script, you simple need to point it to a folder where your source document files are and provide output folder if you wish. If not provided, source folder will also be used as output folder. Here’s how you can run it:</p>
<pre class="brush: ps">convertdoc-tohtml.ps1 -docpath "C:\Documents" -htmlpath "C:\Output"
</pre>
<p>If you want to know how the script can be transformed to save as different format, refer to wdSaveFormat Enumeration members on <a href="http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.wdsaveformat(office.11).aspx">MSDN</a>.</p>
<p>Originally posted at http://blogs.technet.com/bshukla</p>
<div id="pfButton"><a href="http://www.bhargavs.com/index.php/2010/07/28/how-to-convert-a-word-document-to-other-formats-using-powershell/?pfstyle=wp" title="Print an optimized version of this web page"><img id="printfriendly" style="border:none; padding:0;" src="http://cdn.printfriendly.com/pf-button.gif" alt="Print"/></a></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bhargavs?a=_akZiYspJ_c:evURiz6a9jY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bhargavs?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bhargavs?a=_akZiYspJ_c:evURiz6a9jY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/bhargavs?i=_akZiYspJ_c:evURiz6a9jY:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bhargavs/~4/_akZiYspJ_c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bhargavs.com/index.php/2010/07/28/how-to-convert-a-word-document-to-other-formats-using-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bhargavs.com/index.php/2010/07/28/how-to-convert-a-word-document-to-other-formats-using-powershell/</feedburner:origLink></item>
		<item>
		<title>Deceiving scopes of variables in a function</title>
		<link>http://feedproxy.google.com/~r/bhargavs/~3/_avg3QNjmJc/</link>
		<comments>http://www.bhargavs.com/index.php/2010/07/07/deceiving-scopes-of-variables-in-a-function/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 21:04:34 +0000</pubDate>
		<dc:creator>Bhargav</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.bhargavs.com/index.php/2010/07/07/deceiving-scopes-of-variables-in-a-function/</guid>
		<description><![CDATA[I was recently troubleshooting a script when I came across a problem where a variable with defined scope was not retaining its value even though scope seemed correct. Let’s look at simplified example below:
Function Global:Name-ofaFunction
{
$Global:VariableinQuestion = $null
$VariableinQuestion = "Value"
$VariableinQuestion
}

Name-ofaFunction
$VariableinQuestion

The function “Name-ofaFunction” when called, creates a variable with global scope and sets its value to null. [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently troubleshooting a script when I came across a problem where a variable with defined scope was not retaining its value even though scope seemed correct. Let’s look at simplified example below:</p>
<pre class="brush: vb; smart-tabs: false;">Function Global:Name-ofaFunction
{
$Global:VariableinQuestion = $null
$VariableinQuestion = "Value"
$VariableinQuestion
}

Name-ofaFunction
$VariableinQuestion
</pre>
<p>The function “Name-ofaFunction” when called, creates a variable with global scope and sets its value to null. Next, it sets the value of a variable and prints current value to host. Part of the script, I am also calling variable after running the function. This helps me verify the value.</p>
<p>When you run this script, however, you will notice that it prints current value (“Value”) of the variable only once.</p>
<p>If you debug the code, you will notice that the variable is set to null when exiting the function! Interesting why that is happening when you have defined the variable scope to be global in line 3!!!</p>
<p>So let’s try this code.</p>
<pre class="brush: vb; smart-tabs: false;">Function Global:Name-ofaFunction
{
#$Global:VariableinQuestion = $null
$global:VariableinQuestion = "Value"
$VariableinQuestion
}

Name-ofaFunction
$VariableinQuestion
</pre>
<p>If you notice the difference, I have commented out line 3. Also, in line 4, I have added global scope to the variable. If you run this code, you will get the value of the variable printed to the host twice. Once inside the function and second time after the function!</p>
<p>How did that happen? The code doesn’t look much different. Only difference is where I define global scope. Why should that matter? Let me explain.</p>
<p>Although I am not sure if it is a feature or a bug, it seems PowerShell is resetting variable scope to local in line 4 in first example. Because it resets the scope to local, the variable loses its value and is set to null when exiting the function. This is because the variable is created inside the function and is scoped as local for the function. This is fixed in second example by defining it as global right where I am setting its value.</p>
<p>As you can imagine, there are many uses of setting correct scope of the variable. i.e. You may want to use the value returned by the function in another function. When you set the scope properly, the values are retained in appropriate scopes which can be used by other piece of code like functions of cmdlets run on host.</p>
<p>For more information on scope, you can read my previous blog post “<a href="http://www.bhargavs.com/index.php/2010/02/19/powershell-variables-and-scopes/">PowerShell Variables and Scopes</a>” and TechNet article “<a href="http://technet.microsoft.com/en-us/library/dd315289.aspx">about_Scopes</a>”.</p>
<p>Originally posted at http://blogs.technet.com/bshukla</p>
<div id="pfButton"><a href="http://www.bhargavs.com/index.php/2010/07/07/deceiving-scopes-of-variables-in-a-function/?pfstyle=wp" title="Print an optimized version of this web page"><img id="printfriendly" style="border:none; padding:0;" src="http://cdn.printfriendly.com/pf-button.gif" alt="Print"/></a></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bhargavs?a=_avg3QNjmJc:qXSDD4ibE-Y:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bhargavs?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bhargavs?a=_avg3QNjmJc:qXSDD4ibE-Y:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/bhargavs?i=_avg3QNjmJc:qXSDD4ibE-Y:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bhargavs/~4/_avg3QNjmJc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bhargavs.com/index.php/2010/07/07/deceiving-scopes-of-variables-in-a-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bhargavs.com/index.php/2010/07/07/deceiving-scopes-of-variables-in-a-function/</feedburner:origLink></item>
		<item>
		<title>Script to configure static ports on Exchange Server 2010</title>
		<link>http://feedproxy.google.com/~r/bhargavs/~3/W4BydT7Vlg0/</link>
		<comments>http://www.bhargavs.com/index.php/2010/05/19/script-to-configure-static-ports-on-exchange-server-2010/#comments</comments>
		<pubDate>Wed, 19 May 2010 21:31:22 +0000</pubDate>
		<dc:creator>Bhargav</dc:creator>
				<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.bhargavs.com/index.php/2010/05/19/script-to-configure-static-ports-on-exchange-server-2010/</guid>
		<description><![CDATA[If you are planning to implement or are implementing Exchange Server 2010, you may have already noticed that with new changes introduced in this version we highly recommend that you load balance your CAS servers using hardware load balancer. The client connections are not mediated through RPC Client Access service on CAS and that’s why [...]]]></description>
			<content:encoded><![CDATA[<p>If you are planning to implement or are implementing Exchange Server 2010, you may have already noticed that with new changes introduced in this version we highly recommend that you load balance your CAS servers using hardware load balancer. The client connections are not mediated through RPC Client Access service on CAS and that’s why load balancing CAS is very important.</p>
<p>Now if you know how Outlook clients work with Exchange RPC/MAPI, you may as well be aware that it uses random high ports for connection to the Exchange servers. This may not work well when you try to configure your hardware load balancer device. There are many other reasons why you may decide that you would rather use a static port or two for services that need it. It also makes it easy to configure network devices to work with few ports than a whole upper range of high ports.</p>
<p>To that matter, TechNet article “<a href="http://technet.microsoft.com/en-us/library/ff625248.aspx">Load Balancing Requirements of Exchange Protocols</a>” has done a great job documenting how you can configure static ports on CAS and Mailbox servers. <a href="http://social.technet.microsoft.com/wiki/members/Henrik-Walther/default.aspx">Henrik Walther</a> has also provided some more details on TechNet wiki article “<a href="http://social.technet.microsoft.com/wiki/contents/articles/configuring-static-rpc-ports-on-an-exchange-2010-client-access-server.aspx">Configuring Static RPC Ports on an Exchange 2010 Client Access Server</a>”.</p>
<p>Now only if you had the script to do it all for you so you can enjoy doing other things that may be more important or interesting to you… <img src='http://www.bhargavs.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Well, that’s why I have created this script… just for YOU!</p>
<p>So, how do I run the script?</p>
<p>There are few ways you can run it. One is to just call the script with your server name.</p>
<pre class="brush:ps">&#038; 'c:\scripts\Set-StaticPorts.ps1' -Server Server1</pre>
<p>This will change RPC and Address Book ports on the server you specify.</p>
<p>If you want to change many servers, store your servers in a variable and pipe it. Use whichever method works for you to create the array variable with servers you need. One example is to use text file containing one server per line:</p>
<pre class="brush:ps">$Servers = Get-Content c:\scripts\servers.txt
$Servers | Foreach {&#038; 'c:\scripts\Set-StaticPorts.ps1' -Server $_}</pre>
<p>The script can be run remotely as long as you have proper permissions on the server to change registry and exchange configuration files.</p>
<p>So far, in examples above, we did not specify which ports to use for each service. The script accommodates for this by having default values 7575 and 7576 for RPC Service and Address Book Service respectively. But what if you want to specify your own ports? Run:</p>
<pre class="brush:ps">&#038; 'c:\scripts\Set-StaticPorts.ps1' -Server Server1 -rpcport "50000" -abport "50001"</pre>
<p>This will allow you to define your own ports. Just ensure you are not using well known ports or ports in use by other services in your environment to avoid any conflict or confusion.</p>
<p>The script is noisy as you may notice when you run it. It is intentional. It will prompt for your confirmation when changing ports if they are already changed before. It will ask for confirmation before restarting services. Now you may say, I am running the script and I know what I am doing. Well, let the force be with you. –force parameter I mean!</p>
<pre class="brush:ps">&#038; 'c:\scripts\Set-StaticPorts.ps1' -Server Server1 -rpcport "50000' -abport "50001" –force $true</pre>
<p>
  <br />And this will silcence prompting. It will still write output for each server to the host. You can redirect it to a file as well! </p>
<p></p>
<pre class="brush:ps">&#038; 'c:\scripts\Set-StaticPorts.ps1' -Server Server1 -rpcport "50000" -abport "50001" –force $true | out-file c:\scripts\results.txt</pre>
<p>So, where is this script? You can download it here: <a href="http://cid-14adc5cf1e0cbccf.skydrive.live.com/self.aspx/.Public/Exchange%202010/Scripts/Set-StaticPorts.ps1">Set-StaticPorts.ps1</a></p>
<p>If you are still reading, here’s the actual script to refer:</p>
<pre class="brush:ps">
# FUTURE, Update to run with -auto to find cas servers and run automatically
# FUTURE, Update to rung with -auto to find PF stores and run on PF host
#############################################################################
# Set-StaticPorts.ps1
# This script will configure static ports for RPC Client Access and
# Address Book Service on Exchange 2010 CAS servers.
#
# Usage syntax:
# Set-StaticPorts [-Server] <string[]> [-rpcport] <string[]> [-abport] <string[]> [-force] <boolean[]>
#
# Usage Examples:
# Set-StaticPorts -Server Server1 -rpcport "50000" -abport "50001" -force $true
# Set-StaticPorts -Server Server1
#
# Use this script in accordance to the following Technet wiki article:
# http://social.technet.microsoft.com/wiki/contents/articles/configuring-static-rpc-ports-on-an-exchange-2010-client-access-server.aspx
#
# Created by
# Bhargav Shukla
# http://blogs.technet.com/bshukla
# http://www.bhargavs.com
#
# DISCLAIMER
# ==========
# THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE
# RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
#############################################################################

# Declare Parameters with defaults
param([string]$server,[string]$rpcport = '7575',[string]$abport = '7576',[bool]$force = $false)

# Filter to set tcp-port, for avoiding redundancy in the code that follows
function tcp-port
{
	if (($regkey.getvalue($VALUE)) -eq $null)
	{
		# Create / Set TCP/IP Port key and value
		$regKey.Setvalue('TCP/IP Port', "$rpcport", 'Dword')

		# Make changes effective immediately
		$regKey.Flush()

		# Read and store current value
		$global:TCPPort = $regkey.getvalue($VALUE)	

		# Close registry key
		$regKey.Close()

		Write-Host -ForegroundColor Green "TCP/IP Port for RPC Client Access is set to $TCPPort on server $server."
	}
	else
	{
		if (($regkey.getvalue($VALUE)) -ne $rpcport)
		{
			$rpccurrport = $regkey.getvalue($VALUE)
			If (($force) -or (Read-Host "Change the RPC Client Service port from $rpccurrport to $rpcport ? [Y/N]") -eq "Y")
			{
				# Create / Set TCP/IP Port key and value
				$regKey.Setvalue('TCP/IP Port', "$rpcport", 'Dword')

				# Make changes effective immediately
				$regKey.Flush()

				# Read and store current value
				$global:TCPPort = $regkey.getvalue($VALUE)	

				# Close registry key
				$regKey.Close()

				Write-Host -ForegroundColor Green "TCP/IP Port for RPC Client Access is set to $TCPPort on server $server."
			}
			else
			{
				Write-Host -ForegroundColor Green "No changes to RPC Client Service port are made on server $server."
			}
		}
		else
		{
			Write-Host -ForegroundColor Green "No changes to RPC Client Service port are necessary on server $server."
		}
	}
}

function get-installpath
{
	# Set Exchange base key and value to read
	$Reg_ExSetup = "SOFTWARE\\Microsoft\\ExchangeServer\\v14\\Setup"
	$VALUE = "MsiInstallPath"

	# Set regKey for MsiInstallPath
	$regKey= $reg.OpenSubKey($REG_ExSetup)

	# Get Install Path from Registry and replace : with $
	$installPath = ($regkey.getvalue($VALUE) | foreach {$_ -replace (":","`$")})

	# Set Address Book Service config file path
	$global:ABFile = "\\$Server\$installPath"+"Bin\microsoft.exchange.addressbook.service.exe.config"

	# Close registry key
	$regKey.Close()
}

function restart-services
{
	# Restart Microsoft Exchange RPC Client Access and Microsoft Exchange Address Book service
	#### You must specify a timeout (in seconds) or the script could potentially never end
	$TimeOut = 30

	#### This will stop a single service on all servers in sequence
	$ServiceFilters = "(name = 'msexchangerpc')","(name = 'msexchangeab')"

	$Locator = new-object -com "WbemScripting.SWbemLocator"
	$WMI = $Locator.ConnectServer($Server, "root\cimv2")
	# Stop Service and check for timeout or sucessful stop
		$ServiceFilters | %{
			$ThisFilter = $_
			(Get-WmiObject -Class Win32_Service -ComputerName $Server -filter "$ThisFilter AND state='running'") | %{
				$Service = $_
				$Refresher = new-object -comobject "WbemScripting.SWbemRefresher"
				$FreshObject = $Refresher.Add($WMI,$Service.__RELPATH)
				$Refresher.Refresh()
				$Then = Get-Date
				:Checking Do {
					$Service.StopService() | out-null
					$Refresher.Refresh()
					if (($FreshObject.Object.properties_ | ?{$_.name -eq "state"}).value -eq "Stopped")
					{
						Write-Warning "Service $($Service.Name) is stopped on server $Server."
						break :Checking;
					} Else {
						If (((Get-Date) - $Then).seconds -ge $TimeOut)
						{
							Write-Warning "Service $($Service.Name) timed out while trying to stop on server $Server. Please restart service manually."
							break :Checking;
						}
					}
				} While ($True)
			}
		}

	# Start Service and check for timeout or sucessful start
		$ServiceFilters | %{
			$ThisFilter = $_
			(Get-WmiObject -Class Win32_Service -ComputerName $Server -filter "$ThisFilter AND state='Stopped'") | %{
				$Service = $_
				$Refresher = new-object -comobject "WbemScripting.SWbemRefresher"
				$FreshObject = $Refresher.Add($WMI,$Service.__RELPATH)
				$Refresher.Refresh()
				$Then = Get-Date
				:Checking Do {
					$Service.StartService() | out-null
					$Refresher.Refresh()
					if (($FreshObject.Object.properties_ | ?{$_.name -eq "state"}).value -eq "running")
					{
						Write-Host "Service $($Service.Name) started successfully on server $Server"
						break :Checking;
					} Else {
						If (((Get-Date) - $Then).seconds -ge $TimeOut)
						{
							Write-Warning "Service $($Service.Name) timed out while trying to start on server $Server. Please restart service manually."
							break :Checking;
						}
					}
				} While ($True)
			}
		}
}

If ($server)
{
	# Set Registry Key variables
	$REG_BASE = "System\\CurrentControlSet\\Services\\MSExchangeRPC"
	$REG_KEY = "System\\CurrentControlSet\\Services\\MSExchangeRPC\\ParametersSystem"
	$VALUE = 'TCP/IP Port'

	# Open remote registry
	$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Server)

	# Open the targeted remote registry key/subkey as read/write
	$regKey = $reg.OpenSubKey($REG_KEY,$true)

	# Create/Modify Key and Values as necessary
	if ($regKey)
	{
	tcp-port
	}
	else
	{
	$regBase = $reg.OpenSubKey($REG_BASE,$true)
	$regBase.CreateSubKey('ParametersSystem')
	$regBase.Close()
	# Open the targeted remote registry key/subkey as read/write
	$regKey = $reg.OpenSubKey($REG_KEY,$true)
	tcp-port
	}

	# Get location of Address Book Service configuration file
	get-installpath

	# Verify the file exists, exit if it doesn't
	if (Test-Path $ABFile -ErrorAction SilentlyContinue)
	{
		# Backup file before editing
		$currentDate = (get-date).tostring("MM_dd_yyyy-hh_mm_s")
		$ABbackup = $ABFile + ".$currentDate"
		$xml = [xml](get-content $ABFile)
		$xml.Save($ABbackup)

		# Edit RpcTcpPort if 0, ask user for approval if not 0
		$root = $xml.get_DocumentElement();
		ForEach ($item in $root.appSettings.add)
		{
		if (($item.key -eq "RpcTcpPort") -and ($item.value -eq "0"))
			{
				$item.value="$abport"
				Write-Host -ForegroundColor Green "TCP/IP Port for Address Book Service is set to $ABPort on server $server."
			}
			else
			{
			If (($item.key -eq "RpcTcpPort") -and ($item.value -ne "$abport"))
				{
				if (($force) -or (Read-Host "Change port from $($item.value) to $abport on server $server ? [Y/N]") -eq "Y")
					{
						$item.value="$abport"
						Write-Host -ForegroundColor Green "TCP/IP Port for Address Book Service is set to $ABPort on server $server."
					}
				else
					{
						Write-Host -ForegroundColor Green "No changes are made to TCP/IP Port for Address Book Service on server $server."
					}
				}
			}
		}
		$xml.Save($ABFile)
	}
	else
	{
	Write-Host -ForegroundColor Red -BackgroundColor Black "Address Book Service configuration file does not exist for server $server. Please verify file and update manually."
	}

	# Ask for and restart services if requested
	If (($force) -or (Read-Host "Restart services MSExchangeRPC and MSExchangeAB? [Y/N]") -eq "Y")
		{
			restart-services
		}
		else
		{
			Write-Warning "Please restart the Microsoft Exchange RPC Client Access (MSExchangeRPC) service for changes to take effect."
		}

	# Reminder for MAilbox Servers
	Write-Warning "Please do not forget to change ports on Mailbox servers for Public Folder Access."
}
else
{
Write-Host -ForegroundColor Red -BackgroundColor Black "Server Name is null. Please provide Server where static ports need to be set."
Write-Host -ForegroundColor Red -BackgroundColor Black "The syntax is 'Set-StaticPorts.ps1 `"servername`" `"1234`" `"1235`"'."
Write-Host -ForegroundColor Red -BackgroundColor Black "Please replace values of `"1234`" and `"1235`" with valid port numbers for RPC and Address Book Services respectively."
}
</pre>
<p>
  <br />This is a cross post from <a href="http://blogs.technet.com/bshukla" target="_blank">http://blogs.technet.com/bshukla</a></p>
<div id="pfButton"><a href="http://www.bhargavs.com/index.php/2010/05/19/script-to-configure-static-ports-on-exchange-server-2010/?pfstyle=wp" title="Print an optimized version of this web page"><img id="printfriendly" style="border:none; padding:0;" src="http://cdn.printfriendly.com/pf-button.gif" alt="Print"/></a></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bhargavs?a=W4BydT7Vlg0:jY6gh5Lu92s:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bhargavs?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bhargavs?a=W4BydT7Vlg0:jY6gh5Lu92s:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/bhargavs?i=W4BydT7Vlg0:jY6gh5Lu92s:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bhargavs/~4/W4BydT7Vlg0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bhargavs.com/index.php/2010/05/19/script-to-configure-static-ports-on-exchange-server-2010/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		<feedburner:origLink>http://www.bhargavs.com/index.php/2010/05/19/script-to-configure-static-ports-on-exchange-server-2010/</feedburner:origLink></item>
		<item>
		<title>Disaster Recovery</title>
		<link>http://feedproxy.google.com/~r/bhargavs/~3/icDlpShwJFg/</link>
		<comments>http://www.bhargavs.com/index.php/2010/05/03/hello-world/#comments</comments>
		<pubDate>Mon, 03 May 2010 18:35:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Announcements]]></category>

		<guid isPermaLink="false">http://bhargavs.com/?p=1</guid>
		<description><![CDATA[As many may have noticed already, my site had been unavailable for days. I was able to finally move to a better host, and recover content from backups. I however have lingering issues like missing images and some other miscellaneous items.
I appreciate  your patience and hope this will not happen again. I would also like [...]]]></description>
			<content:encoded><![CDATA[<p>As many may have noticed already, my site had been unavailable for days. I was able to finally move to a better host, and recover content from backups. I however have lingering issues like missing images and some other miscellaneous items.</p>
<p>I appreciate  your patience and hope this will not happen again. I would also like to let you know that I have also created blog at <a href="http://blogs.technet.com/bshukla">http://blogs.technet.com/bshukla</a>. The content will be cross posted so it will be available to both here and at my technet blog. This way you can continue following my articles either way.</p>
<p>Lastly, I would like to thank you for your patience while I worked on restoring my site from catastrophic failure.</p>
<div id="pfButton"><a href="http://www.bhargavs.com/index.php/2010/05/03/hello-world/?pfstyle=wp" title="Print an optimized version of this web page"><img id="printfriendly" style="border:none; padding:0;" src="http://cdn.printfriendly.com/pf-button.gif" alt="Print"/></a></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bhargavs?a=icDlpShwJFg:oCh1LkI0zzg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bhargavs?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bhargavs?a=icDlpShwJFg:oCh1LkI0zzg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/bhargavs?i=icDlpShwJFg:oCh1LkI0zzg:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bhargavs/~4/icDlpShwJFg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bhargavs.com/index.php/2010/05/03/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bhargavs.com/index.php/2010/05/03/hello-world/</feedburner:origLink></item>
		<item>
		<title>How to install Update Rollups remotely on Exchange 2010 server</title>
		<link>http://feedproxy.google.com/~r/bhargavs/~3/PFj5fcZ3cmo/</link>
		<comments>http://www.bhargavs.com/index.php/2010/04/07/how-to-install-update-rollups-remotely-on-exchange-2010-server/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 21:22:00 +0000</pubDate>
		<dc:creator>Bhargav</dc:creator>
				<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.bhargavs.com/index.php/2010/04/07/how-to-install-update-rollups-remotely-on-exchange-2010-server/</guid>
		<description><![CDATA[If you are like me, you are always looking for ways to not leave your chair, or for that matter, not switch windows.
When it comes to install Update Rollups on every Exchange 2010 server you have, the same applies. So I set out to find a way and I found one! Even though this requires [...]]]></description>
			<content:encoded><![CDATA[<p>If you are like me, you are always looking for ways to not leave your chair, or for that matter, not switch windows.</p>
<p>When it comes to install Update Rollups on every Exchange 2010 server you have, the same applies. So I set out to find a way and I found one! Even though this requires some work upfront, it will make it easy ever after.</p>
<h5>Pre-Requisites:</h5>
<p>The cost of making it easier for future is the work you have to do now. Well, let’s get to it. In order to be able to connect to your Exchange servers remotely, you will need to configure winrm (if not configured already). All you need to do is run
<pre class="brush: powershell">winrm quickconfig</pre>
<p>from elevated PowerShell session (run as administrator). The command adds an HTTP listener, configures the server to allow remote requests, and creates a Firewall exception rule. I am assuming that you are running Windows Server 2008 R2. I have not tested this on other server versions, however it should work if PowerShell v2 and WinRM is installed correctly.</p>
<h5>Script:</h5>
<p>So, how do I run the script?</p>
<pre class="brush: powershell">Get-Content “\\server\share\servers.txt” | Foreach-Object {Invoke-Command –ComputerName $_ –FilePath “\\server\share\Install-UpdateRollups.ps1”}</pre>
<p>The command will read list of servers from servers.txt (specify your path where it reads <a href="file://server/share/servers.txt" mce_href="file://\\server\share\servers.txt">\\server\share\servers.txt</a>) and call script to install Update Rollup specified in the script. Notice that I am user serialization by piping. This way I am running update only on one server at a time. The command could be change to look like this:</p>
<pre class="brush: powershell">Invoke-Command –ComputerName (Get-Content “\\server\share\servers.txt”) –FilePath “\\server\share\Install-UpdateRollups.ps1”</pre>
<p>however, I have not tested it on multiple computers and unsure of the success using this method.</p>
<p>After the installation of Update Rollup, the script will prompt user for reboot and if user approves, script will also reboot the server.</p>
<p>So, a million dollar question is, where is this script? You can download it here: <a href="http://cid-14adc5cf1e0cbccf.skydrive.live.com/self.aspx/.Public/Blog-TechNet/Install-UpdateRollups.ps1" target="_blank" mce_href="http://cid-14adc5cf1e0cbccf.skydrive.live.com/self.aspx/.Public/Blog-TechNet/Install%2DUpdateRollups%2Eps1">Install-UpdateRollups.ps1</a></p>
<p>The code is pasted below for reference:</p>
<pre class="brush: powershell; ruler: true; auto-links: true">
#############################################################################
# Install-UpdateRollups.ps1
# Remotely installs Update Rollups on Exchange 2007 or Exchange 2010 servers
#
# Pre-requisites
# --------------
# Requires winrm enabled on destination servers. Run winrm quickconfig to enable.
# Requires write access to $Log_Drive folder and $Install_Drive folder if "Logs"
#   folder doesn't exist in $Install_Drive.
#
# Created by
# Bhargav Shukla
# http://blogs.technet.com/bshukla
# http://www.bhargavs.com
#
# DISCLAIMER
# ==========
# THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE
# RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
#############################################################################

#Update variables to reflect correct locations and Update Rollup installer file name
$Install_Drive = "\\server\share"
$RU_File = "installer.msp"
$Log_Drive = "$Install_Drive\Logs"
$ServerName = $Env:COMPUTERNAME

# Check for RU install file
$CheckRUPath = "$Install_Drive\$RU_File"
Write-Host -ForegroundColor Green "Checking for $CheckRUPath"
if (-not (Test-Path $CheckRUPath))
{
	Write-Host -ForegroundColor Red "ERROR: Update Rollup File not found!"
	Write-Host -ForegroundColor Red "ERROR: Exiting."
	exit
}

# Check for Logs path, create folder if doesn't exist
$CheckLogPath = "$Log_Drive"
Write-Host -ForegroundColor Green "Checking for $CheckLogPath"
if (-not (Test-Path $CheckLogPath))
{
	Write-Host -ForegroundColor Yellow "ERROR: Log Folder not found!"
	Write-Host -ForegroundColor Yellow "INFO:  Creating Log Folder..."
	New-Item -Path $Install_Drive -Name Logs -itemtype directory -Force
}

# Disable "Check for publisher's certificate revocation"
Write-Host ""
Write-Host -ForegroundColor Green "Disabling publisher's certificate revocation check..."
set-ItemProperty -path "HKCU:\Software\Microsoft\Windows\CurrentVersion\WinTrust\Trust Providers\Software Publishing" -name State -value 146944

Write-Host -ForegroundColor Green "Installing Exchange Update Rollup..."
	$oProcess = [System.Diagnostics.Process]::Start("$Install_Drive\$RU_File", " /passive /lv $Log_Drive\$ServerName-InstallRollup.log /norestart")
	$oProcess.WaitForExit() 

# Enable "Check for publisher's certificate revocation"
Write-Host -ForegroundColor Green "Re-enabling Check for publisher's certificate revocation..."
Set-ItemProperty -path "HKCU:Software\Microsoft\Windows\CurrentVersion\WinTrust\Trust Providers\Software Publishing" -name State -value 146432

# Reboot if user responds [Y]es
if ((Read-Host "Reboot? [Y/N]") -eq "Y")
{
write-host -ForegroundColor Red "Rebooting Server $ServerName."
Restart-Computer
}
</pre>
<h5>Update:</h5>
<p>I failed to mention the effect of double-hops and delegation of authentication for the remote installation mentioned above to work. Here’s why it is a problem:</p>
<p>Your install files and list of servers are located on a server (let’s call it ServerA). You are running the invoke-command from a client computer (let’s call it ClientA) and you are going to install RU on Exchange servers (let’s call it EXA, EXB and EXC). When you run the command, get-content is run is local runspace of ClientA and works fine. The next step is to pipe the servernames to invoke-command. The install script mentioned above is then called from share on ServerA. However, this is now remote runspace on exchange servers EXA, EXB and EXC. The error you will notice is when the install script checks for existence of RU file. Even if the RU file exists in mentioned share and permissions are given to account you are using to run the commands from ClientA, you will see that script errors and exits unexpectedly. It thinks the RU file doesn’t exist when it actually does!</p>
<p>That is because, your credentials from ClientA are passed to EXA, however, to access the file on ServerA, your credentials needs to be passed on to it. This is delegation. And we have not configured any delegation yet! This will cause script block to fail since it can’t access the RU file without access.</p>
<p>How can you solve this? Here are the steps:</p>
<p>1. on ClientA run:</p>
<pre class="brush: powershell">Enable-wsmancredssp -role client –delegatecomputer *</pre>
<p>This will enable credssp delegation from ClientA to computers you define in –delegatecomputer. In our example, we allowed delegation to all computer by using * which is ok for lab. In production environment, you may want to restrict it to your domain name (i.e. *.domain.com) or list of servers (i.e. EXA.domain.com, EXB.domain.com, EXC.domain.com).</p>
<p>2. on all target servers, EXA, EXB and EXC in our example, run:</p>
<pre class="brush: powershell">Enable-wsmancredssp -role server</pre>
<p>This will allow target servers to use credentials specified by ClientA using CredSSP to access files on ServerA.</p>
<p>3. on ClientA, run the install command:</p>
<pre class="brush: powershell">$cred = Get-Credential
Get-Content “\\server\share\servers.txt” | Foreach-Object {Invoke-Command –ComputerName $_ –FilePath “\\server\share\Install-UpdateRollups.ps1” –Authentication CredSSP –Credential $cred}</pre>
<p>Notice the use of CredSSP and explicit specification of credentials. This is important and required for the remote install process to work.</p>
<p>One more gotcha. The process above does not work if your ClientA isn’t Windows 7, Vista or Windows Server 2008. This is because CredSSP isn’t available to Windows XP or Windows Server 2003. You can host your share on Windows Server 2003, however, you must run step 1 and 3 from a client that is capable of using CredSSP.</p>
<p>Here are some references for further reading:</p>
<p><a title="http://msdn.microsoft.com/en-us/library/ee309365%28VS.85%29.aspx" href="http://msdn.microsoft.com/en-us/library/ee309365%28VS.85%29.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ee309365%28VS.85%29.aspx">Multi-Hop Support in WinRM</a></p>
<p><a href="http://blogs.technet.com/brad_rutkowski/archive/2008/09/26/using-invoke-command-to-launch-a-script-on-a-remote-computer-which-connects-to-network-resources.aspx" mce_href="http://blogs.technet.com/brad_rutkowski/archive/2008/09/26/using-invoke-command-to-launch-a-script-on-a-remote-computer-which-connects-to-network-resources.aspx">Using invoke-command to launch a script on a remote computer which connects to network resources</a></p>
<p><a title="http://technet.microsoft.com/en-us/library/dd819517.aspx" href="http://technet.microsoft.com/en-us/library/dd819517.aspx" mce_href="http://technet.microsoft.com/en-us/library/dd819517.aspx">Enable-WSManCredSSP</a></p>
<p mce_keep="true">&nbsp;</p>
<p><strong><em>This article is also posted to </em></strong><a href="http://www.bhargavs.com/" mce_href="http://www.bhargavs.com"><strong><em>http://www.bhargavs.com</em></strong></a></p>
<div id="pfButton"><a href="http://www.bhargavs.com/index.php/2010/04/07/how-to-install-update-rollups-remotely-on-exchange-2010-server/?pfstyle=wp" title="Print an optimized version of this web page"><img id="printfriendly" style="border:none; padding:0;" src="http://cdn.printfriendly.com/pf-button.gif" alt="Print"/></a></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bhargavs?a=PFj5fcZ3cmo:36-fClrlASQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bhargavs?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bhargavs?a=PFj5fcZ3cmo:36-fClrlASQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/bhargavs?i=PFj5fcZ3cmo:36-fClrlASQ:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bhargavs/~4/PFj5fcZ3cmo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bhargavs.com/index.php/2010/04/07/how-to-install-update-rollups-remotely-on-exchange-2010-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bhargavs.com/index.php/2010/04/07/how-to-install-update-rollups-remotely-on-exchange-2010-server/</feedburner:origLink></item>
		<item>
		<title>Script to enable preview pane for PowerShell scripts</title>
		<link>http://feedproxy.google.com/~r/bhargavs/~3/XOsCBP7ELZ0/</link>
		<comments>http://www.bhargavs.com/index.php/2010/03/29/script-to-enable-preview-pane-for-powershell-scripts/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 07:17:17 +0000</pubDate>
		<dc:creator>Bhargav</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.bhargavs.com/index.php/2010/03/29/script-to-enable-preview-pane-for-powershell-scripts/</guid>
		<description><![CDATA[If you are running Windows 7, you probably know what preview pane is. And if you use PowerShell and create ps1 scripts, you may also wonder how can you enable preview for PowerShell scripts in Windows Explorer.
Well, Nate Bruneau shared how to edit registry to enable preview for ps1 scripts. Being a scripter myself, I [...]]]></description>
			<content:encoded><![CDATA[<p>If you are running Windows 7, you probably know what preview pane is. And if you use PowerShell and create ps1 scripts, you may also wonder how can you enable preview for PowerShell scripts in Windows Explorer.</p>
<p>Well, Nate Bruneau shared how to edit registry to enable preview for ps1 scripts. Being a scripter myself, I figured I would wrap it into a nice script and share it with everyone. Thanks Nate for your permission.</p>
<p>The scrip runs on Windows 7 and Windows Server 2008 R2. You must run it from elevated PowerShell session. The script uses elevation code from <a href="http://www.interact-sw.co.uk/iangblog/2007/02/09/pshdetectelevation" target="_blank">Ian Griffiths’ blog</a> to check for elevation and exits with notification if PowerShell is not running as administrator.</p>
<p>Here’s the script:</p>
<pre class="brush: powershell; ruler: true; auto-links: true; toolbar: true">#############################################################################
# Enable-ps1Preview.ps1
# This script will enable preview for ps1 files in Windows Explorer.
# Special thanks to Nate Bruneau for the idea.
#
# Created by
# Bhargav Shukla
# http://www.bhargavs.com
#
# DISCLAIMER
# ==========
# THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE
# RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
#############################################################################

# Check if OS is Windows 7 or Windows Server 2008 R2, quit if not.
$OS = (Get-WmiObject -Class win32_OperatingSystem).caption
switch -wildcard ($OS)
{
  &quot;*Windows 7*&quot; {&quot;`nChecking Elevation...&quot;}
  &quot;*Windows Server 2008 R2*&quot; {&quot;`nChecking Elevation...&quot;}
  default {Write-Host -ForegroundColor Red &quot;`nYou are not running Windows 7 or Windows Server 2008 R2. You can't use this feature on older OS.&quot;; exit}
}

# Function to check if PowerShell is running elevated
function Check-Elevated
{
  $wid=[System.Security.Principal.WindowsIdentity]::GetCurrent()
  $prp=new-object System.Security.Principal.WindowsPrincipal($wid)
  $adm=[System.Security.Principal.WindowsBuiltInRole]::Administrator
  $IsAdmin=$prp.IsInRole($adm)
  if ($IsAdmin)
  {
    Set-Variable -Name elevated -Value $true -Scope 1
  }
}

# Make registry changes if running elevated, throw error if not
Check-Elevated
If ($elevated -eq $true)
{
	# Set Registry Key variables
	$REG_KEY = &quot;.ps1&quot;

	# Open remote registry
	$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot', &quot;.&quot;)

	# Open the targeted remote registry key/subkey as read/write
	$regKey = $reg.OpenSubKey($REG_KEY,$true)

	# Set PerceivedType to &quot;text&quot;
	if ($regKey -ne $null)
	{
		$regKey.Setvalue('PerceivedType', 'text', 'String')
		$regKey.Setvalue('Content Type', 'text/plain', 'String')

		# Close the Reg Key
		$regKey.Close()

		Write-Host -ForegroundColor Green -BackgroundColor Black &quot;Preview for .ps1 files is now enabled. Enable preview pane in Windows Explorer.`n&quot;

	}

}
else
{
  Write-Host -ForegroundColor Red -BackgroundColor Black &quot;Please run PowerShell as administrator before you run this script.`n&quot;
}</pre>
<p>You can download the script here – <a href="http://cid-14adc5cf1e0cbccf.skydrive.live.com/self.aspx/.Public/Blog-Bhargavs/Exchange/Enable-ps1Preview.ps1" target="_blank">Enable-ps1Preview.ps1</a></p>
<div id="pfButton"><a href="http://www.bhargavs.com/index.php/2010/03/29/script-to-enable-preview-pane-for-powershell-scripts/?pfstyle=wp" title="Print an optimized version of this web page"><img id="printfriendly" style="border:none; padding:0;" src="http://cdn.printfriendly.com/pf-button.gif" alt="Print"/></a></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bhargavs?a=XOsCBP7ELZ0:x1lRHwL00IE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bhargavs?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bhargavs?a=XOsCBP7ELZ0:x1lRHwL00IE:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/bhargavs?i=XOsCBP7ELZ0:x1lRHwL00IE:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bhargavs/~4/XOsCBP7ELZ0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bhargavs.com/index.php/2010/03/29/script-to-enable-preview-pane-for-powershell-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bhargavs.com/index.php/2010/03/29/script-to-enable-preview-pane-for-powershell-scripts/</feedburner:origLink></item>
		<item>
		<title>Script to suppress Link State Updates</title>
		<link>http://feedproxy.google.com/~r/bhargavs/~3/rnnBU-hqP34/</link>
		<comments>http://www.bhargavs.com/index.php/2010/03/25/script-to-suppress-link-state-updates/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 06:50:35 +0000</pubDate>
		<dc:creator>Bhargav</dc:creator>
				<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[CoExistence]]></category>
		<category><![CDATA[Exchange 2003]]></category>
		<category><![CDATA[Suppress Link State Updates]]></category>

		<guid isPermaLink="false">http://www.bhargavs.com/index.php/exchange-server/exchange-2010-exchange-server/2010/03/script-to-suppress-link-state-updates/</guid>
		<description><![CDATA[If you are in process of upgrading from Exchange 2003 to Exchange 2010, you must have read “Upgrade from Exchange 2003 Transport” article on Technet which spells out the details of a requirement &#8211; “minor link state updates must be suppressed to make sure that message looping doesn&#8217;t occur when a route is recalculated”. 
I [...]]]></description>
			<content:encoded><![CDATA[<p>If you are in process of upgrading from Exchange 2003 to Exchange 2010, you must have read “<a href="http://technet.microsoft.com/en-us/library/dd638103.aspx" target="_blank">Upgrade from Exchange 2003 Transport</a>” article on Technet which spells out the details of a requirement &#8211; “<strong><em>minor link state updates must be suppressed to make sure that message looping doesn&#8217;t occur when a route is recalculated</em></strong>”. </p>
<p>I will not go into details of the requirement, however, if you read the details in the “<a href="http://technet.microsoft.com/en-us/library/aa996728.aspx" target="_blank">Suppress Link State Updates</a>” article, you know that the task can be daunting, especially if you have multiple Exchange 2003 servers, possibly in geographically dispersed locations.</p>
<p>Well, sweat no more. I have written a script that will help you get it done easily. Here’s the script:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;">#############################################################################</span>
<span style="color: #008000;"># Suppress-Linkstate.ps1</span>
<span style="color: #008000;"># Using static text file or Get-ExchangeServer, this script will configure</span>
<span style="color: #008000;"># selected Exchange 2003 servers to suppress Link State to aid in upgrade to</span>
<span style="color: #008000;"># Exchange Server 2010 environment.</span>
<span style="color: #008000;">#</span>
<span style="color: #008000;"># Use this script in accordance to the following Technet article</span>
<span style="color: #008000;"># http://technet.microsoft.com/en-us/library/aa996728.aspx</span>
<span style="color: #008000;">#</span>
<span style="color: #008000;"># Created by</span>
<span style="color: #008000;"># Bhargav Shukla</span>
<span style="color: #008000;"># http://www.bhargavs.com</span>
<span style="color: #008000;">#</span>
<span style="color: #008000;"># DISCLAIMER</span>
<span style="color: #008000;"># ==========</span>
<span style="color: #008000;"># THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE</span>
<span style="color: #008000;"># RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.</span>
<span style="color: #008000;">#############################################################################</span>
&nbsp;
<span style="color: #0000FF;">function</span> Suppress<span style="color: pink;">-</span>Linkstate
<span style="color: #000000;">&#123;</span>
<span style="color: #008000;"># Create empty results file or overwrite existing file</span>
<span style="color: #800000;">&quot;Server Name,SuppressStateChanges,ServiceStopState,ServiceStartState&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-File</span> .\results.csv <span style="color: #008080; font-style: italic;">-Encoding</span> ASCII
&nbsp;
	<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Server</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$Servers</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #008000;"># Do Nothing if $_ is null</span>
		<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Server</span> <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
		<span style="color: #008000;"># Set server to connect to</span>
		<span style="color: #008000;">#$Server = &quot;$_&quot;</span>
&nbsp;
		<span style="color: #008000;"># Read SuppressStateChanges from servers</span>
&nbsp;
			<span style="color: #008000;"># Set Registry Key variables</span>
			<span style="color: #800080;">$REG_KEY</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;System\\CurrentControlSet\\Services\\RESvc\\Parameters&quot;</span>
			<span style="color: #800080;">$VALUE</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;SuppressStateChanges&quot;</span>
&nbsp;
			<span style="color: #008000;"># Open remote registry</span>
			<span style="color: #800080;">$reg</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>Microsoft.Win32.RegistryKey<span style="color: #000000;">&#93;</span>::OpenRemoteBaseKey<span style="color: #000000;">&#40;</span><span style="color: #800000;">'LocalMachine'</span><span style="color: pink;">,</span> <span style="color: #800080;">$Server</span><span style="color: #000000;">&#41;</span>
&nbsp;
			<span style="color: #008000;"># Open the targeted remote registry key/subkey as read/write</span>
			<span style="color: #800080;">$regKey</span> <span style="color: pink;">=</span> <span style="color: #800080;">$reg</span>.OpenSubKey<span style="color: #000000;">&#40;</span><span style="color: #800080;">$REG_KEY</span><span style="color: pink;">,</span><span style="color: #800080;">$true</span><span style="color: #000000;">&#41;</span>
&nbsp;
			<span style="color: #008000;"># Set SuppressStateChanges to 1 if key exists</span>
			<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$regKey</span> <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$regKey</span>.Setvalue<span style="color: #000000;">&#40;</span><span style="color: #800000;">'SuppressStateChanges'</span><span style="color: pink;">,</span> <span style="color: #800000;">'1'</span><span style="color: pink;">,</span> <span style="color: #800000;">'Dword'</span><span style="color: #000000;">&#41;</span>
&nbsp;
			<span style="color: #008000;"># Write changes to registry without closing it</span>
			<span style="color: #800080;">$regKey</span>.Flush<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
			<span style="color: #008000;"># Read and Store SuppressStateChanges value in variable</span>
			<span style="color: #800080;">$SuppressStateChanges</span> <span style="color: pink;">=</span> <span style="color: #800080;">$regkey</span>.getvalue<span style="color: #000000;">&#40;</span><span style="color: #800080;">$VALUE</span><span style="color: #000000;">&#41;</span>
&nbsp;
			<span style="color: #008000;"># Close the Reg Key</span>
			<span style="color: #800080;">$regKey</span>.Close<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #008000;"># Restart SMTP service, the Microsoft Exchange Routing Engine service, and the Microsoft Exchange MTA Stacks service</span>
		<span style="color: #008000;">#### You must specify a timeout (in seconds) or the script could potentially never end</span>
		<span style="color: #800080;">$TimeOut</span> <span style="color: pink;">=</span> <span style="color: #000000;">30</span>
&nbsp;
		<span style="color: #008000;">#### This will stop a single service on all servers in sequence</span>
		<span style="color: #800080;">$ServiceFilters</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;(name = 'smtpsvc')&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;(name = 'resvc')&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;(name = 'msexchangemta')&quot;</span>
&nbsp;
&nbsp;
			<span style="color: #800080;">$Locator</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> <span style="color: pink;">-</span>com <span style="color: #800000;">&quot;WbemScripting.SWbemLocator&quot;</span>
			<span style="color: #800080;">$WMI</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Locator</span>.ConnectServer<span style="color: #000000;">&#40;</span><span style="color: #800080;">$Server</span><span style="color: pink;">,</span> <span style="color: #800000;">&quot;root\cimv2&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #008000;"># Stop Service and check for timeout or sucessful stop</span>
			<span style="color: #800080;">$ServiceFilters</span> <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span>
				<span style="color: #800080;">$ThisFilter</span> <span style="color: pink;">=</span> <span style="color: #000080;">$_</span>
				<span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Get-WmiObject</span> <span style="color: #008080; font-style: italic;">-Class</span> Win32_Service <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$Server</span> <span style="color: pink;">-</span><span style="color: #0000FF;">filter</span> <span style="color: #800000;">&quot;$ThisFilter AND state='running'&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span>
					<span style="color: #800080;">$Service</span> <span style="color: pink;">=</span> <span style="color: #000080;">$_</span>
					<span style="color: #800080;">$Refresher</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> <span style="color: #008080; font-style: italic;">-comobject</span> <span style="color: #800000;">&quot;WbemScripting.SWbemRefresher&quot;</span>
					<span style="color: #800080;">$FreshObject</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Refresher</span>.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$WMI</span><span style="color: pink;">,</span><span style="color: #800080;">$Service</span>.__RELPATH<span style="color: #000000;">&#41;</span>
					<span style="color: #800080;">$Refresher</span>.Refresh<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
					<span style="color: #800080;">$Then</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Date</span>
					:Checking <span style="color: #0000FF;">Do</span> <span style="color: #000000;">&#123;</span>
						<span style="color: #800080;">$Service</span>.StopService<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">out-null</span>
						<span style="color: #800080;">$Refresher</span>.Refresh<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
						<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$FreshObject</span>.Object.properties_ <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.name <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;state&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>.value <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;Stopped&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
							<span style="color: #800080;">$ServiceStopState</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Service $($Service.Name) stopped&quot;</span>;
&nbsp;
							<span style="color: #008000;"># Store result string in a variable</span>
							<span style="color: #800080;">$result</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;$Server,$SuppressStateChanges,$ServiceStopState,$ServiceStartState&quot;</span>
&nbsp;
							<span style="color: #008000;"># Write results to file</span>
							<span style="color: #800080;">$result</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-File</span> .\results.csv <span style="color: #008080; font-style: italic;">-Encoding</span> ASCII <span style="color: #008080; font-style: italic;">-Append</span>
&nbsp;
							<span style="color: #800080;">$ServiceStopState</span> <span style="color: pink;">=</span> <span style="color: #800080;">$null</span>
&nbsp;
							<span style="color: #0000FF;">break</span> :Checking;
						<span style="color: #000000;">&#125;</span> <span style="color: #0000FF;">Else</span> <span style="color: #000000;">&#123;</span>
							<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Get-Date</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">-</span> <span style="color: #800080;">$Then</span><span style="color: #000000;">&#41;</span>.seconds <span style="color: #FF0000;">-ge</span> <span style="color: #800080;">$TimeOut</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
								<span style="color: #800080;">$ServiceStopState</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Service $($Service.Name) stop TIMEOUT&quot;</span>;
&nbsp;
								<span style="color: #008000;"># Store result string in a variable</span>
								<span style="color: #800080;">$result</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;$Server,$SuppressStateChanges,$ServiceStopState,$ServiceStartState&quot;</span>
&nbsp;
								<span style="color: #008000;"># Write results to file</span>
								<span style="color: #800080;">$result</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-File</span> .\results.csv <span style="color: #008080; font-style: italic;">-Encoding</span> ASCII <span style="color: #008080; font-style: italic;">-Append</span>
&nbsp;
								<span style="color: #800080;">$ServiceStopState</span> <span style="color: pink;">=</span> <span style="color: #800080;">$null</span>
&nbsp;
								<span style="color: #0000FF;">break</span> :Checking;
							<span style="color: #000000;">&#125;</span>
						<span style="color: #000000;">&#125;</span>
					<span style="color: #000000;">&#125;</span> <span style="color: #0000FF;">While</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$True</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #008000;"># Start Service and check for timeout or sucessful start</span>
			<span style="color: #800080;">$ServiceFilters</span> <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span>
				<span style="color: #800080;">$ThisFilter</span> <span style="color: pink;">=</span> <span style="color: #000080;">$_</span>
				<span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Get-WmiObject</span> <span style="color: #008080; font-style: italic;">-Class</span> Win32_Service <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$Server</span> <span style="color: pink;">-</span><span style="color: #0000FF;">filter</span> <span style="color: #800000;">&quot;$ThisFilter AND state='Stopped'&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span>
					<span style="color: #800080;">$Service</span> <span style="color: pink;">=</span> <span style="color: #000080;">$_</span>
					<span style="color: #800080;">$Refresher</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> <span style="color: #008080; font-style: italic;">-comobject</span> <span style="color: #800000;">&quot;WbemScripting.SWbemRefresher&quot;</span>
					<span style="color: #800080;">$FreshObject</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Refresher</span>.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$WMI</span><span style="color: pink;">,</span><span style="color: #800080;">$Service</span>.__RELPATH<span style="color: #000000;">&#41;</span>
					<span style="color: #800080;">$Refresher</span>.Refresh<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
					<span style="color: #800080;">$Then</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Date</span>
					:Checking <span style="color: #0000FF;">Do</span> <span style="color: #000000;">&#123;</span>
						<span style="color: #800080;">$Service</span>.StartService<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">out-null</span>
						<span style="color: #800080;">$Refresher</span>.Refresh<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
						<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$FreshObject</span>.Object.properties_ <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.name <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;state&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>.value <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;running&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
							<span style="color: #800080;">$ServiceStartState</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Service $($Service.Name) started&quot;</span>;
&nbsp;
							<span style="color: #008000;"># Store result string in a variable</span>
							<span style="color: #800080;">$result</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;$Server,$SuppressStateChanges,$ServiceStopState,$ServiceStartState&quot;</span>
&nbsp;
							<span style="color: #008000;"># Write results to file</span>
							<span style="color: #800080;">$result</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-File</span> .\results.csv <span style="color: #008080; font-style: italic;">-Encoding</span> ASCII <span style="color: #008080; font-style: italic;">-Append</span>
&nbsp;
							<span style="color: #800080;">$ServiceStartState</span> <span style="color: pink;">=</span> <span style="color: #800080;">$null</span>
&nbsp;
							<span style="color: #0000FF;">break</span> :Checking;
						<span style="color: #000000;">&#125;</span> <span style="color: #0000FF;">Else</span> <span style="color: #000000;">&#123;</span>
							<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Get-Date</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">-</span> <span style="color: #800080;">$Then</span><span style="color: #000000;">&#41;</span>.seconds <span style="color: #FF0000;">-ge</span> <span style="color: #800080;">$TimeOut</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
								<span style="color: #800080;">$ServiceStartState</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Service $($Service.Name) start TIMEOUT&quot;</span>;
&nbsp;
								<span style="color: #008000;"># Store result string in a variable</span>
								<span style="color: #800080;">$result</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;$Server,$SuppressStateChanges,$ServiceStopState,$ServiceStartState&quot;</span>
&nbsp;
								<span style="color: #008000;"># Write results to file</span>
								<span style="color: #800080;">$result</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-File</span> .\results.csv <span style="color: #008080; font-style: italic;">-Encoding</span> ASCII <span style="color: #008080; font-style: italic;">-Append</span>
&nbsp;
								<span style="color: #800080;">$ServiceStartState</span> <span style="color: pink;">=</span> <span style="color: #800080;">$null</span>
&nbsp;
								<span style="color: #0000FF;">break</span> :Checking;
							<span style="color: #000000;">&#125;</span>
						<span style="color: #000000;">&#125;</span>
					<span style="color: #000000;">&#125;</span> <span style="color: #0000FF;">While</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$True</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #008000;">#Add Exchange 2010 snapin if not loaded</span>
<span style="color: #008000;"># Uncomment following four (4) lines if using dynamic list mentioned below</span>
<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Get-PSSnapin</span> <span style="color: pink;">|</span> <span style="color: #0000FF;">where</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Name <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;E2010&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #008080; font-weight: bold;">Add-PSSnapin</span> Microsoft.Exchange.Management.PowerShell.E2010
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;"># Uncomment next line if you want to dynamically get Exchange 2003 servers using Exchange 2010 Management Shell</span>
<span style="color: #800080;">$Servers</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span>get<span style="color: pink;">-</span>exchangeserver <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Where-Object</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.AdminDisplayVersion <span style="color: #FF0000;">-like</span> <span style="color: #800000;">'*6.5*'</span><span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">ForEach-Object</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Name<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>
<span style="color: #008000;"># Comment line above and Uncomment next line if you want to provide list of servers in a text file (one server per line)</span>
<span style="color: #008000;"># You can't have both of the abovementioned lines uncommented. Please use one of your choice.</span>
<span style="color: #008000;"># $Servers = Get-Content .\servers.txt</span>
&nbsp;
<span style="color: #800080;">$Servers</span> <span style="color: pink;">|</span> Suppress<span style="color: pink;">-</span>Linkstate</pre></td></tr></table></div>

<p>Few important pointers:</p>
<ul>
<li>The script can use one of the two methods, please comment and uncomment necessary lines as documented in script</li>
</ul>
<p>&#160;&#160;&#160;&#160; &#8211; Dynamically retrieve list of Exchange 2003 servers in your environment using Get-ExchangeServer cmdlet from an Exchange 2010 server</p>
<p>&#160;&#160;&#160;&#160; &#8211; Use list of Exchange 2003 servers provided in servers.txt file (one server per line)</p>
<ul>
<li>If you choose to use dynamic method, you&#160; must have Exchange server 2010 admin tools installed on the machine where the script is run from</li>
<li>The output will be store in results.csv file</li>
<li>Timeout value in line 62 works fine in my lab tests, it may not work for you. Please adjust the value as necessary</li>
</ul>
<p>You can download the script from here: <a href="http://cid-14adc5cf1e0cbccf.skydrive.live.com/self.aspx/.Public/Blog-Bhargavs/Exchange/Suppress-Linkstate.ps1" target="_blank">Suppress-Linkstate.ps1</a></p>
<p>I am sure there are ways to optimize and improve this script. I would love to know how I can make the script better and more useful. Please feel free to drop me a line using <a href="http://www.bhargavs.com/index.php/contact/">contact form</a>. I will be happy to hear your feedback and improve script. You can also use comments option on this post to leave your feedback.</p>
<div id="pfButton"><a href="http://www.bhargavs.com/index.php/2010/03/25/script-to-suppress-link-state-updates/?pfstyle=wp" title="Print an optimized version of this web page"><img id="printfriendly" style="border:none; padding:0;" src="http://cdn.printfriendly.com/pf-button.gif" alt="Print"/></a></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bhargavs?a=rnnBU-hqP34:PFoX1Bo8FYQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bhargavs?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bhargavs?a=rnnBU-hqP34:PFoX1Bo8FYQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/bhargavs?i=rnnBU-hqP34:PFoX1Bo8FYQ:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bhargavs/~4/rnnBU-hqP34" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bhargavs.com/index.php/2010/03/25/script-to-suppress-link-state-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.bhargavs.com/index.php/2010/03/25/script-to-suppress-link-state-updates/</feedburner:origLink></item>
	</channel>
</rss>
