<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en" xml:base="http://blog.usepowershell.com/wp-atom.php">
	<title type="text">Use PowerShell</title>
	<subtitle type="text">Real Admins Script</subtitle>

	<updated>2010-07-17T14:38:56Z</updated>

	<link rel="alternate" type="text/html" href="http://blog.usepowershell.com" />
	<id>http://blog.usepowershell.com/feed/atom/</id>
	

	<generator uri="http://wordpress.org/" version="3.0.1">WordPress</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/UsePowershell" /><feedburner:info uri="usepowershell" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
		<author>
			<name>Steven Murawski</name>
						<uri>http://www.usepowershell.com</uri>
					</author>
		<title type="html"><![CDATA[Adding Configuration To Remoting]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UsePowershell/~3/Z_Kys1qYBp0/" />
		<id>http://blog.usepowershell.com/2010/07/adding-configuration-to-remoting/</id>
		<updated>2010-07-17T14:38:56Z</updated>
		<published>2010-07-16T14:25:57Z</published>
		<category scheme="http://blog.usepowershell.com" term="PowerShell" /><category scheme="http://blog.usepowershell.com" term="PowerShell Version 2" /><category scheme="http://blog.usepowershell.com" term="Tip" />		<summary type="html"><![CDATA[This is a pretty brief post that will need some further elaboration, but Twitter doesn’t provide the best mechanism for longer examples. There are two places where you can configure your remote sessions.. 1) On the remote server – which is covered in a number of places and probably the most discoverable place to put [...]]]></summary>
		<content type="html" xml:base="http://blog.usepowershell.com/2010/07/adding-configuration-to-remoting/">&lt;p&gt;This is a pretty brief post that will need some further elaboration, but Twitter doesn’t provide the best mechanism for longer examples.&lt;/p&gt;
&lt;p&gt;There are two places where you can configure your remote sessions.. &lt;/p&gt;
&lt;p&gt;1) On the remote server – which is covered in a number of places and probably the most discoverable place to put configuration information..&amp;#160; See the help for &lt;a href="http://technet.microsoft.com/en-us/library/dd819508.aspx" target="_blank"&gt;about_Session_Configurations&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;2) Locally, when you start the PSSession.&amp;#160; This is where we will dig deeper.&lt;/p&gt;
&lt;p&gt;&amp;#160;&lt;/p&gt;
&lt;p&gt;One of the cool, lesser covered features in remoting is the ability to persist a remote connection to a module.&amp;#160; After you establish a PSSession, you can use &lt;a href="http://technet.microsoft.com/en-us/library/dd347679.aspx" target="_blank"&gt;Export-PSSession&lt;/a&gt; to create a module that will hold the commands to create the proxies for the commands in that session, as well as the plumbing to recreate that session.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://technet.microsoft.com/en-us/library/dd347679.aspx" target="_blank"&gt;Export-PSSession&lt;/a&gt; will create a script module, which you can modify to work how you would like..&amp;#160; &lt;/p&gt;
&lt;p&gt;In the module, one of the functions generated is the Get-PSImplicitRemotingSession function.&amp;#160; When you call one of the commands from the imported session, it will get the saved PSSession.&amp;#160; If the session has not been established yet, the Set-PsImplicitRemotingSession function will be called, creating the session.&amp;#160; You can add your any commands you would like after that.. &lt;/p&gt;
&lt;p&gt;For example I’m using Invoke-Command below to import a module once the session is connected.&amp;#160; That script block can be anything you need to do to configure your remote session. (NOTE: The Set-PSImplicitRemotingSession is generated by the command, I’m only adding code after that and using the $script:PSSession object that is created.&lt;/p&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #0000ff"&gt;Set-PSImplicitRemotingSession&lt;/span&gt; &lt;span style="color: #000000"&gt;`
&lt;/span&gt;            &lt;span style="color: #000080"&gt;-CreatedByModule&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$true&lt;/span&gt; &lt;span style="color: #000000"&gt;`
&lt;/span&gt;            &lt;span style="color: #000080"&gt;-PSSession&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;
            &lt;span style="color: #000000"&gt;$(&lt;/span&gt;
                &lt;span style="color: #a9a9a9"&gt;&amp;amp;&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$script:NewPSSession&lt;/span&gt; &lt;span style="color: #000000"&gt;`
&lt;/span&gt;                    &lt;span style="color: #000080"&gt;-ComputerName&lt;/span&gt; &lt;span style="color: #8b0000"&gt;'192.168.16.150'&lt;/span&gt; &lt;span style="color: #000000"&gt;`
&lt;/span&gt;                    &lt;span style="color: #000080"&gt;-ApplicationName&lt;/span&gt; &lt;span style="color: #8b0000"&gt;'/wsman'&lt;/span&gt;    &lt;span style="color: #000080"&gt;-ConfigurationName&lt;/span&gt; &lt;span style="color: #8b0000"&gt;'Microsoft.PowerShell'&lt;/span&gt; &lt;span style="color: #000000"&gt;`
&lt;/span&gt;                    &lt;span style="color: #000080"&gt;-SessionOption&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #0000ff"&gt;Get-PSImplicitRemotingSessionOption&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt; &lt;span style="color: #000000"&gt;`
&lt;/span&gt;                    &lt;span style="color: #000080"&gt;-Credential&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$host&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;UI&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;PromptForCredential&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt; &lt;span style="color: #8b0000"&gt;'Windows PowerShell Credential Request'&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #8b0000"&gt;'Enter your credentials for http://192.168.16.150/wsman.'&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #8b0000"&gt;'phoenix\steve.murawski'&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #8b0000"&gt;'192.168.16.150'&lt;/span&gt; &lt;span style="color: #000000"&gt;)&lt;/span&gt; &lt;span style="color: #000000"&gt;)&lt;/span&gt; &lt;span style="color: #000000"&gt;`
&lt;/span&gt;                     &lt;span style="color: #000000"&gt;`
&lt;/span&gt;                    &lt;span style="color: #000080"&gt;-Authentication&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Default&lt;/span&gt; &lt;span style="color: #000000"&gt;`
&lt;/span&gt;                   &lt;span style="color: #000000"&gt;`
&lt;/span&gt;            &lt;span style="color: #000000"&gt;)&lt;/span&gt;
            &lt;span style="color: #000000"&gt;)&lt;/span&gt;            

          &lt;span style="color: #0000ff"&gt;Invoke-Command&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt;&lt;span style="color: #0000ff"&gt;Import-Module&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;TaskScheduler&lt;/span&gt;&lt;span style="color: #000000"&gt;}&lt;/span&gt; &lt;span style="color: #000080"&gt;-Session&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$script:PSSession&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/azQgPfQfmp7ciAeiDy35LYjv7Hg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/azQgPfQfmp7ciAeiDy35LYjv7Hg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/azQgPfQfmp7ciAeiDy35LYjv7Hg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/azQgPfQfmp7ciAeiDy35LYjv7Hg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/UsePowershell?a=Z_Kys1qYBp0:7AtiCVvjaE4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/UsePowershell?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/UsePowershell/~4/Z_Kys1qYBp0" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://blog.usepowershell.com/2010/07/adding-configuration-to-remoting/#comments" thr:count="3" />
		<link rel="replies" type="application/atom+xml" href="http://blog.usepowershell.com/2010/07/adding-configuration-to-remoting/feed/atom/" thr:count="3" />
		<thr:total>3</thr:total>
	<feedburner:origLink>http://blog.usepowershell.com/2010/07/adding-configuration-to-remoting/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Steven Murawski</name>
						<uri>http://www.usepowershell.com</uri>
					</author>
		<title type="html"><![CDATA[Chicago Code Camp &#8211; May 1]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UsePowershell/~3/xDBybaEOG9A/" />
		<id>http://blog.usepowershell.com/2010/04/chicago-code-camp-may-1/</id>
		<updated>2010-04-28T22:00:07Z</updated>
		<published>2010-04-28T22:00:07Z</published>
		<category scheme="http://blog.usepowershell.com" term="General" />		<summary type="html"><![CDATA[The Chicago Code Camp is being held on Saturday, May 1st.&#160; I’ll be presenting a PowerShell Deep Dive.&#160; If you are in the Chicago area and want to get down into the guts of the PowerShell language and runtime (or many other great sessions!), come on out.&#160; There were 100 97 tickets available last time [...]]]></summary>
		<content type="html" xml:base="http://blog.usepowershell.com/2010/04/chicago-code-camp-may-1/">&lt;p&gt;The &lt;a href="http://chicagocodecamp.com/" target="_blank"&gt;Chicago Code Camp&lt;/a&gt; is being held on Saturday, May 1st.&amp;#160; I’ll be presenting a PowerShell Deep Dive.&amp;#160; If you are in the Chicago area and want to get down into the guts of the PowerShell language and runtime (&lt;a href="http://chicagocodecamp.com/agenda" target="_blank"&gt;or many other great sessions!&lt;/a&gt;), come on out.&amp;#160; &lt;a href="http://chicagocodecamp.eventbrite.com/" target="_blank"&gt;There were &lt;strike&gt;100&lt;/strike&gt; 97 tickets available last time I checked…&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/xNeSh7pQRecNKWn694rYiufowh4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xNeSh7pQRecNKWn694rYiufowh4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/xNeSh7pQRecNKWn694rYiufowh4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xNeSh7pQRecNKWn694rYiufowh4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/UsePowershell?a=xDBybaEOG9A:8aDbUoWH3nU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/UsePowershell?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/UsePowershell/~4/xDBybaEOG9A" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://blog.usepowershell.com/2010/04/chicago-code-camp-may-1/#comments" thr:count="4" />
		<link rel="replies" type="application/atom+xml" href="http://blog.usepowershell.com/2010/04/chicago-code-camp-may-1/feed/atom/" thr:count="4" />
		<thr:total>4</thr:total>
	<feedburner:origLink>http://blog.usepowershell.com/2010/04/chicago-code-camp-may-1/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Steven Murawski</name>
						<uri>http://www.usepowershell.com</uri>
					</author>
		<title type="html"><![CDATA[April Script Club &#8211; Special Guest]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UsePowershell/~3/w8trWwnboL0/" />
		<id>http://blog.usepowershell.com/2010/04/april-script-club-special-guest/</id>
		<updated>2010-04-14T20:11:03Z</updated>
		<published>2010-04-14T20:11:03Z</published>
		<category scheme="http://blog.usepowershell.com" term="General" />		<summary type="html"><![CDATA[The Greater Milwaukee Script Club will be meeting on April 20th and we will have a special guest – James Brundage (twitter &#124; blog &#124; blog).&#160; James is a member of the PowerShell team at Microsoft, as well as a blogger, community member, guest on the PowerScripting Podcast, and author of the PowerShellPack – part [...]]]></summary>
		<content type="html" xml:base="http://blog.usepowershell.com/2010/04/april-script-club-special-guest/">&lt;p&gt;The &lt;a href="http://powershellgroup.org/milwaukee.wi" target="_blank"&gt;Greater Milwaukee Script Club&lt;/a&gt; &lt;a href="http://mkescriptclub.eventbrite.com" target="_blank"&gt;will be meeting on April 20th&lt;/a&gt; and we will have a special guest – James Brundage (&lt;a href="http://twitter.com/jamesbru" target="_blank"&gt;twitter&lt;/a&gt; | &lt;a href="http://blogs.msdn.com/MediaAndMicrocode/" target="_blank"&gt;blog&lt;/a&gt; | &lt;a href="http://blogs.msdn.com/powershell/" target="_blank"&gt;blog&lt;/a&gt;).&amp;#160; James is a member of the PowerShell team at Microsoft, as well as a blogger, community member, guest on the &lt;a href="http://powerscripting.net/" target="_blank"&gt;PowerScripting Podcast&lt;/a&gt;, and author of the &lt;a href="http://code.msdn.microsoft.com/PowerShellPack" target="_blank"&gt;PowerShellPack&lt;/a&gt; – part of the Windows Resource Kit.&lt;/p&gt;
&lt;p&gt;Last month, we used the &lt;a href="http://blogs.msdn.com/powershell/archive/2007/01/01/the-admin-development-model-and-send-snippet.aspx" target="_blank"&gt;Admin Development Model&lt;/a&gt; to solve a particular problem &lt;a href="http://www.liquidclever.com/" target="_blank"&gt;one of our brave volunteers&lt;/a&gt; was trying to deal with in his environment. &lt;/p&gt;
&lt;p&gt;We have planned to talk a bit about error handling, and as always, work on &lt;strong&gt;your&lt;/strong&gt; scripts.&lt;/p&gt;
&lt;p&gt;If you are a PowerShell user or need to become a PowerShell user and are in southeastern Wisconsin, come on down, all are welcome (&lt;a href="http://mkescriptclub.eventbrite.com" target="_blank"&gt;free registration requested&lt;/a&gt;)!&lt;/p&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/HbrZhAgp8xCE3hnyHTnGB6YF9U4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/HbrZhAgp8xCE3hnyHTnGB6YF9U4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/HbrZhAgp8xCE3hnyHTnGB6YF9U4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/HbrZhAgp8xCE3hnyHTnGB6YF9U4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/UsePowershell?a=w8trWwnboL0:APVNTEYRe4Q:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/UsePowershell?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/UsePowershell/~4/w8trWwnboL0" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://blog.usepowershell.com/2010/04/april-script-club-special-guest/#comments" thr:count="1" />
		<link rel="replies" type="application/atom+xml" href="http://blog.usepowershell.com/2010/04/april-script-club-special-guest/feed/atom/" thr:count="1" />
		<thr:total>1</thr:total>
	<feedburner:origLink>http://blog.usepowershell.com/2010/04/april-script-club-special-guest/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Steven Murawski</name>
						<uri>http://www.usepowershell.com</uri>
					</author>
		<title type="html"><![CDATA[Wisconsin Virtual SQL Server Lunch and Learn]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UsePowershell/~3/do44hwSALGU/" />
		<id>http://blog.usepowershell.com/2010/02/wisconsin-virtual-sql-server-lunch-and-learn/</id>
		<updated>2010-02-26T18:46:21Z</updated>
		<published>2010-02-26T18:46:21Z</published>
		<category scheme="http://blog.usepowershell.com" term="General" />		<summary type="html"><![CDATA[I just finished taking up 13 people’s lunch hour to talk a bit about PowerShell V2, SQL Server, and the admin development model. I want to thank John Allman and the Wisconsin SQL Server User Group for allowing me the time to share a bit about PowerShell.&#160; I believe John will be posting the recording [...]]]></summary>
		<content type="html" xml:base="http://blog.usepowershell.com/2010/02/wisconsin-virtual-sql-server-lunch-and-learn/">&lt;p&gt;I just finished taking up 13 people’s lunch hour to talk a bit about &lt;a href="http://msdn.microsoft.com/en-us/library/ms714418(VS.85).aspx" target="_blank"&gt;PowerShell&lt;/a&gt; V2, SQL Server, and the &lt;a href="http://blogs.msdn.com/powershell/archive/2007/01/01/the-admin-development-model-and-send-snippet.aspx" target="_blank"&gt;admin development model&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I want to thank &lt;a href="http://wisconsin.sqlpass.org/" target="_blank"&gt;John Allman and the Wisconsin SQL Server User Group&lt;/a&gt; for allowing me the time to share a bit about PowerShell.&amp;#160; I believe John will be posting the recording for those who are interested.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://download.usepowershell.com/PowerShellV2.pptx" target="_blank"&gt;My slide deck is available here.&lt;/a&gt;&amp;#160; The slides aren’t worth much, but the resources on the last two are where the real meat is.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Tzeo7dzDZpuLpmJ2mDt5Z2qPJbI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Tzeo7dzDZpuLpmJ2mDt5Z2qPJbI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Tzeo7dzDZpuLpmJ2mDt5Z2qPJbI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Tzeo7dzDZpuLpmJ2mDt5Z2qPJbI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/UsePowershell?a=do44hwSALGU:e1rkjxtyzSI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/UsePowershell?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/UsePowershell/~4/do44hwSALGU" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://blog.usepowershell.com/2010/02/wisconsin-virtual-sql-server-lunch-and-learn/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://blog.usepowershell.com/2010/02/wisconsin-virtual-sql-server-lunch-and-learn/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://blog.usepowershell.com/2010/02/wisconsin-virtual-sql-server-lunch-and-learn/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Steven Murawski</name>
						<uri>http://www.usepowershell.com</uri>
					</author>
		<title type="html"><![CDATA[Deep Fried PowerShell]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UsePowershell/~3/sAXWJZlLS6U/" />
		<id>http://blog.usepowershell.com/?p=176</id>
		<updated>2010-02-26T16:50:15Z</updated>
		<published>2010-02-26T16:09:59Z</published>
		<category scheme="http://blog.usepowershell.com" term="General" />		<summary type="html"><![CDATA[Back in August, I was offered a chance to make a fool of myself on yet another podcast tremendously honored by the opportunity to talk with Keith Elder and Chris “Woody” Woodruff on their podcast – Deep Fried Bytes – about PowerShell. Keith and Chris are great guys, very sharp, and asked some good questions.&#160; [...]]]></summary>
		<content type="html" xml:base="http://blog.usepowershell.com/2010/02/deep-fried-powershell/">&lt;p&gt;Back in August, I was &lt;strike&gt;offered a chance to make a fool of myself on yet another podcast&lt;/strike&gt; tremendously honored by &lt;a href="http://deepfriedbytes.com/podcast/episode-46-using-powershell-to-be-more-productive-with-steven-murawski/" target="_blank"&gt;the opportunity&lt;/a&gt; to talk with &lt;a href="http://keithelder.net/blog/" target="_blank"&gt;Keith Elder&lt;/a&gt; and &lt;a href="http://chriswoodruff.com/" target="_blank"&gt;Chris “Woody” Woodruff&lt;/a&gt; on their podcast – &lt;a href="http://deepfriedbytes.com/" target="_blank"&gt;Deep Fried Bytes&lt;/a&gt; – about &lt;a href="http://msdn.microsoft.com/en-us/library/ms714418(VS.85).aspx" target="_blank"&gt;PowerShell&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Keith and Chris are great guys, very sharp, and asked some good questions.&amp;#160; If you pop over to take a listen to my appearance, make sure to go back and take a look through their archives.&amp;#160; They’ve got 45 other shows, all worthwhile.&amp;#160; (I’m a few podcast behind.. still working through &lt;a href="http://deepfriedbytes.com/podcast/episode-37-the-present-and-future-of-workflow-foundation-with-brian-noyes-part-1/" target="_blank"&gt;show #37&lt;/a&gt; – where they are talking about Windows Workflow.&amp;#160; Jut to pull in some PowerShell, there is a PowerShell Activity in WF 4.)&amp;#160; I’m quite looking forward to &lt;a href="http://deepfriedbytes.com/podcast/episode-44-soft-skills-every-developer-needs-with-brian-prince/" target="_blank"&gt;show #44 on soft skills&lt;/a&gt; with &lt;a href="http://brianhprince.com/" target="_blank"&gt;Brian Prince&lt;/a&gt;, as I don’t think we in the tech fields focus enough on these.&lt;/p&gt;
&lt;p&gt;If you want to hear more on PowerShell related development, send Keith and Woody some feedback on the show or bother your favorite podcaster to do a show on PowerShell – maybe they’ll ask you to put your Shell where your mouth is…&lt;/p&gt;
&lt;p&gt;&lt;a href="http://deepfriedbytes.com/podcast/episode-46-using-powershell-to-be-more-productive-with-steven-murawski/" target="_blank"&gt;Check out the show here..&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/j86AuyU7OHaKn1H5FcG-_uAFmWw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/j86AuyU7OHaKn1H5FcG-_uAFmWw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/j86AuyU7OHaKn1H5FcG-_uAFmWw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/j86AuyU7OHaKn1H5FcG-_uAFmWw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/UsePowershell?a=sAXWJZlLS6U:7TZzGCZy-Ts:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/UsePowershell?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/UsePowershell/~4/sAXWJZlLS6U" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://blog.usepowershell.com/2010/02/deep-fried-powershell/#comments" thr:count="2" />
		<link rel="replies" type="application/atom+xml" href="http://blog.usepowershell.com/2010/02/deep-fried-powershell/feed/atom/" thr:count="2" />
		<thr:total>2</thr:total>
	<feedburner:origLink>http://blog.usepowershell.com/2010/02/deep-fried-powershell/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Steven Murawski</name>
						<uri>http://www.usepowershell.com</uri>
					</author>
		<title type="html"><![CDATA[Greater Milwaukee Script Club &#8211; Take 2]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UsePowershell/~3/pGQ9SDGa444/" />
		<id>http://blog.usepowershell.com/2010/01/greater-milwaukee-script-club-take-2/</id>
		<updated>2010-01-27T14:25:06Z</updated>
		<published>2010-01-27T14:25:06Z</published>
		<category scheme="http://blog.usepowershell.com" term="General" />		<summary type="html"><![CDATA[We had a pretty good turnout for the first Greater Milwaukee Script Club and a lot of interest in keeping it going, so I’ve set up a home page for the group on Joel “Jaykul” Bennet’s PowerShellGroup.Org site, which serves as a portal page for PowerShell user groups. Rod Gabriel (who heads up our local [...]]]></summary>
		<content type="html" xml:base="http://blog.usepowershell.com/2010/01/greater-milwaukee-script-club-take-2/">&lt;p&gt;We had a pretty good turnout for the first Greater Milwaukee Script Club and a lot of interest in keeping it going, so I’ve set up a &lt;a href="http://powershellgroup.org/milwaukee.wi" target="_blank"&gt;home page for the group&lt;/a&gt; on &lt;a href="http://huddledmasses.org" target="_blank"&gt;Joel “Jaykul” Bennet’s&lt;/a&gt; PowerShellGroup.Org site, which serves as a portal page for PowerShell user groups.&lt;/p&gt;
&lt;p&gt;Rod Gabriel (who heads up our local VMWare User Group) &lt;a href="http://www.wivmug.org/2010/01/my-first-scripting-club-meeting/" target="_blank"&gt;has an excellent review of the event.&lt;/a&gt;&amp;#160; He covers why he considered attending (including why learning PowerShell was becoming a priority for him), as well as the event itself.&lt;/p&gt;
&lt;p&gt;Registration is available for our next meeting – which will be February 16th at 6:00 PM at the Greenfield Municipal Court (&lt;a href="http://mkescriptclub.eventbrite.com/" target="_blank"&gt;details here&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;More details and information to follow..&lt;/p&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Oxhk9vrKQgpUtUWaeOmWn5vOXB4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Oxhk9vrKQgpUtUWaeOmWn5vOXB4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Oxhk9vrKQgpUtUWaeOmWn5vOXB4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Oxhk9vrKQgpUtUWaeOmWn5vOXB4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/UsePowershell?a=pGQ9SDGa444:prjRCr9z0RU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/UsePowershell?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/UsePowershell/~4/pGQ9SDGa444" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://blog.usepowershell.com/2010/01/greater-milwaukee-script-club-take-2/#comments" thr:count="3" />
		<link rel="replies" type="application/atom+xml" href="http://blog.usepowershell.com/2010/01/greater-milwaukee-script-club-take-2/feed/atom/" thr:count="3" />
		<thr:total>3</thr:total>
	<feedburner:origLink>http://blog.usepowershell.com/2010/01/greater-milwaukee-script-club-take-2/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Steven Murawski</name>
						<uri>http://www.usepowershell.com</uri>
					</author>
		<title type="html"><![CDATA[Script Injection with Set-PSBreakpoint]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UsePowershell/~3/seWhajSKDn0/" />
		<id>http://blog.usepowershell.com/2010/01/script-injection-with-set-psbreakpoint/</id>
		<updated>2010-01-12T20:30:05Z</updated>
		<published>2010-01-12T20:15:06Z</published>
		<category scheme="http://blog.usepowershell.com" term="General" /><category scheme="http://blog.usepowershell.com" term="PowerShell" /><category scheme="http://blog.usepowershell.com" term="PowerShell Version 2" />		<summary type="html"><![CDATA[I’ve used the integrated debugging features with PowerShell V2 since I’ve had it available, but I never really dug below the surface of setting breakpoints at certain lines. Set-PSBreakpoint offers some additional options of which I was not aware. Setting a breakpoint in relation to a variable (read, assigned, or both) Setting a breakpoint when [...]]]></summary>
		<content type="html" xml:base="http://blog.usepowershell.com/2010/01/script-injection-with-set-psbreakpoint/">&lt;p&gt;I’ve used the integrated debugging features with &lt;a href="http://support.microsoft.com/kb/968929" target="_blank"&gt;PowerShell V2&lt;/a&gt; since I’ve had it available, but I never really dug below the surface of setting breakpoints at certain lines.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://technet.microsoft.com/en-us/library/dd315264.aspx" target="_blank"&gt;Set-PSBreakpoint&lt;/a&gt; offers some additional options of which I was not aware.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Setting a breakpoint in relation to a variable (read, assigned, or both)&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Setting a breakpoint when a function or command is called&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Setting a breakpoint based on the column number for the referenced line&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Run a scriptblock when a breakpoint is hit&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Breakpoints do not need to be set on a script&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let’s dig into these in a bit more detail:&lt;/p&gt;
&lt;h3&gt;1.  Setting a breakpoint in relation to a variable (read, assigned, or both)&lt;/h3&gt;
&lt;p&gt;Set-PSBreakpoint can be used to find all the occurrences of access to a variable (in the current scope).  This can be very useful when attempting to find out where things might be taking an unexpected turn with your variable’s contents.&lt;/p&gt;
&lt;h3&gt;2. Setting a breakpoint when a function or command is called&lt;/h3&gt;
&lt;p&gt;This is cool.  You can configure breakpoints based on when cmdlets or functions are called.  Great stopping at the entry point to a particularly troublesome function, so you can drop into the debugger and check the state of parameters about to go in, as well as other state related issues.&lt;/p&gt;
&lt;h3&gt;3. Setting a breakpoint based on the column number for the referenced line&lt;/h3&gt;
&lt;p&gt;I’m not so stoked about this feature.  This merely allows you to specify which column to stop execution on in a particular line of code…  Moderately useful, but not really exciting.&lt;/p&gt;
&lt;h3&gt;4. Run a scriptblock when a breakpoint is hit&lt;/h3&gt;
&lt;p&gt;This is where things get interesting.  You can assign an action to occur when a breakpoint is hit.  This action is a scriptblock that is run in the scope where it is set.  Since breakpoints can be variable assignments or calls to commands, this opens up some interesting possibilities.  First off, it allows for conditional debugging.  If you only want to drop into a breakpoint if a particular value is less than zero before going into a function, you could do something like&lt;/p&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #ff4500"&gt;$BreakpointAction&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt;
    &lt;span style="color: #00008b"&gt;if&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$MyNumber&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-lt&lt;/span&gt; &lt;span style="color: #800080"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
    &lt;span style="color: #000000"&gt;{&lt;/span&gt;
        &lt;span style="color: #00008b"&gt;break&lt;/span&gt;
    &lt;span style="color: #000000"&gt;}&lt;/span&gt;
    &lt;span style="color: #00008b"&gt;else&lt;/span&gt;
    &lt;span style="color: #000000"&gt;{&lt;/span&gt;
        &lt;span style="color: #00008b"&gt;continue&lt;/span&gt;
    &lt;span style="color: #000000"&gt;}&lt;/span&gt;
&lt;span style="color: #000000"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;This also has applications outside of debugging.  Using the –Action parameter of Set-PSBreakpoint, you have the ability to run a scripblock of your choosing at any of the condition types described above – when variables are accessed, when commands are called, and at certain specific positions in the script.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h3&gt;5. Breakpoints do not need to be set on a script&lt;/h3&gt;
&lt;p&gt;Finally, breakpoints do not need to be set in a script, they can just be set to respond to variable access or command use.  This means that you could use Set-PSBreakpoint in a profile script to configure a particular environment to respond in a certain way, perhaps prompting you before changing a critical environmental variable.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I’m definitely going to be exploring these additional features and applications of Set-PSBreakpoint as I go forward. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/powershell/archive/2009/07/13/advanced-debugging-in-powershell.aspx" target="_blank"&gt;Additional debugging tips/info from the PowerShell Team Blog.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Please leave a comment as to how you think this functionality could be used.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/_Bz-K8KkyqcPovefMnO_GOjGqMk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_Bz-K8KkyqcPovefMnO_GOjGqMk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/_Bz-K8KkyqcPovefMnO_GOjGqMk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_Bz-K8KkyqcPovefMnO_GOjGqMk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/UsePowershell?a=seWhajSKDn0:56ZYJ2lPM3E:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/UsePowershell?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/UsePowershell/~4/seWhajSKDn0" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://blog.usepowershell.com/2010/01/script-injection-with-set-psbreakpoint/#comments" thr:count="1" />
		<link rel="replies" type="application/atom+xml" href="http://blog.usepowershell.com/2010/01/script-injection-with-set-psbreakpoint/feed/atom/" thr:count="1" />
		<thr:total>1</thr:total>
	<feedburner:origLink>http://blog.usepowershell.com/2010/01/script-injection-with-set-psbreakpoint/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Steven Murawski</name>
						<uri>http://www.usepowershell.com</uri>
					</author>
		<title type="html"><![CDATA[I&#8217;ll be on the PowerScripting Podcast!]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UsePowershell/~3/1atEKFCqAu4/" />
		<id>http://blog.usepowershell.com/?p=164</id>
		<updated>2010-01-11T16:39:33Z</updated>
		<published>2010-01-11T16:39:33Z</published>
		<category scheme="http://blog.usepowershell.com" term="General" />		<summary type="html"><![CDATA[I&#8217;ll be on the PowerScripting podcast with Jonathan Walz and Hal Rottenberg for this week&#8217;s live stream.  We&#8217;ll be talking about PowerShellCommunity.Org, the Sync Framework, and more&#8230; I love that podcast and am really looking forward to it!  Also, they recently posted an interview with Clint Huffman, who is the author of PAL.  Good stuff!]]></summary>
		<content type="html" xml:base="http://blog.usepowershell.com/2010/01/ill-be-on-the-powerscripting-podcast/">&lt;p&gt;&lt;a href="http://powerscripting.wordpress.com/2010/01/11/this-thursday-steven-murawski-talks-about-powershellcommunity-org-and-more/" target="_blank"&gt;I&amp;#8217;ll be on the PowerScripting podcast with Jonathan Walz and Hal Rottenberg for this week&amp;#8217;s live stream&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;We&amp;#8217;ll be talking about PowerShellCommunity.Org, the Sync Framework, and more&amp;#8230;&lt;/p&gt;
&lt;p&gt;I love that podcast and am really looking forward to it! &lt;/p&gt;
&lt;p&gt;Also, they recently posted &lt;a href="http://powerscripting.wordpress.com/2010/01/10/episode-97-clint-huffman-and-his-pal-project/" target="_blank"&gt;an interview &lt;/a&gt;with &lt;a href="http://blogs.technet.com/clinth/" target="_blank"&gt;Clint Huffman&lt;/a&gt;, who is the author of &lt;a href="http://pal.codeplex.com" target="_blank"&gt;PAL&lt;/a&gt;.  Good stuff!&lt;/p&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/D9mHq3x_Z4i5L2hFlVw9rTXecnU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/D9mHq3x_Z4i5L2hFlVw9rTXecnU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/D9mHq3x_Z4i5L2hFlVw9rTXecnU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/D9mHq3x_Z4i5L2hFlVw9rTXecnU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/UsePowershell?a=1atEKFCqAu4:4VI_qhwWMVo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/UsePowershell?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/UsePowershell/~4/1atEKFCqAu4" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://blog.usepowershell.com/2010/01/ill-be-on-the-powerscripting-podcast/#comments" thr:count="1" />
		<link rel="replies" type="application/atom+xml" href="http://blog.usepowershell.com/2010/01/ill-be-on-the-powerscripting-podcast/feed/atom/" thr:count="1" />
		<thr:total>1</thr:total>
	<feedburner:origLink>http://blog.usepowershell.com/2010/01/ill-be-on-the-powerscripting-podcast/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Steven Murawski</name>
						<uri>http://www.usepowershell.com</uri>
					</author>
		<title type="html"><![CDATA[Script Club &#8211; Coming to the Greater Milwaukee Area]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UsePowershell/~3/KUCgYPa0uFc/" />
		<id>http://blog.usepowershell.com/2009/12/script-club-coming-to-the-greater-milwaukee-area/</id>
		<updated>2009-12-08T17:41:50Z</updated>
		<published>2009-12-08T16:06:39Z</published>
		<category scheme="http://blog.usepowershell.com" term="General" /><category scheme="http://blog.usepowershell.com" term="PowerShell" /><category scheme="http://blog.usepowershell.com" term="PowerShell Community" /><category scheme="http://blog.usepowershell.com" term="PowerShell Version 1" /><category scheme="http://blog.usepowershell.com" term="PowerShell Version 2" />		<summary type="html"><![CDATA[Register here. About PowerShell Script Club 1. You Always Talk About Script club 2. You Always Talk About Script Club 3. If Someone asks for Help, And You Can Help, You Help 4. Two People Help One Person at One Time 5. One Module Per Person Per Night 6. All Scripts, All PowerShell 7. Scripts [...]]]></summary>
		<content type="html" xml:base="http://blog.usepowershell.com/2009/12/script-club-coming-to-the-greater-milwaukee-area/">&lt;h3&gt;&lt;strong&gt;&lt;a href="http://mkescriptclub.eventbrite.com " target="_blank"&gt;Register here.&lt;/a&gt;&lt;/strong&gt;&lt;/h3&gt;
&lt;h3&gt;About PowerShell Script Club&lt;/h3&gt;
&lt;p&gt;1. You Always Talk About Script club    &lt;br /&gt;2. You Always Talk About Script Club     &lt;br /&gt;3. If Someone asks for Help, And You Can Help, You Help     &lt;br /&gt;4. Two People Help One Person at One Time     &lt;br /&gt;5. One Module Per Person Per Night     &lt;br /&gt;6. All Scripts, All PowerShell     &lt;br /&gt;7. Scripts will be as short as they can be     &lt;br /&gt;8. If This is your First time at Script Club, You Have to Script&lt;/p&gt;
&lt;h4&gt;The first Greater Milwaukee &lt;a href="http://msdn.microsoft.com/en-us/library/ms714418(VS.85).aspx" target="_blank"&gt;PowerShell&lt;/a&gt; Script Club is being formed.&lt;/h4&gt;
&lt;p&gt;The first meeting will be on Tuesday, January 19th at 6:00 PM at the Greenfield Law Enforcement Center (in the Municipal Court Room), 5300 W Layton Ave, Greenfield, WI&amp;#160; 53220.&amp;#160; &lt;a href="http://mkescriptclub.eventbrite.com " target="_blank"&gt;Register here.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;u&gt;All&lt;/u&gt;&lt;/strong&gt; &lt;strong&gt;IT Professionals (sysadmins, network admins, developers, help desk, and all others) with &lt;u&gt;any level of experience&lt;/u&gt; are welcome.&amp;#160; If you DO NOT KNOW POWERSHELL, but you WANT TO – This is the place.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Pizza and soda will be provided, but please bring a laptop with PowerShell installed (version 1 or 2 is fine).&lt;/p&gt;
&lt;h4&gt;What is a Script Club?&lt;/h4&gt;
&lt;p&gt;&lt;a href="http://get-powershell.com/2009/04/04/powershell-script-club-in-seattle/" target="_blank"&gt;Andy Schneider describes a script club:&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Script Clubs are like a hands on lab with no set topic or teacher. You bring an idea for a script, and ask your fellow PowerShell users for help getting the script written.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is not a lecture or presentation based group (though we may have presentations from time to time).&amp;#160; Script Club is focused on creating working scripts that will help you get your work done or just enjoy yourself.&lt;/p&gt;
&lt;h3&gt;&lt;a href="http://mkescriptclub.eventbrite.com/" target="_blank"&gt;Register here.&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/RXi9facq6dwe9-m2_Q3OYDLTuWM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RXi9facq6dwe9-m2_Q3OYDLTuWM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/RXi9facq6dwe9-m2_Q3OYDLTuWM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RXi9facq6dwe9-m2_Q3OYDLTuWM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/UsePowershell?a=KUCgYPa0uFc:qUb4K6-LCpA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/UsePowershell?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/UsePowershell/~4/KUCgYPa0uFc" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://blog.usepowershell.com/2009/12/script-club-coming-to-the-greater-milwaukee-area/#comments" thr:count="6" />
		<link rel="replies" type="application/atom+xml" href="http://blog.usepowershell.com/2009/12/script-club-coming-to-the-greater-milwaukee-area/feed/atom/" thr:count="6" />
		<thr:total>6</thr:total>
	<feedburner:origLink>http://blog.usepowershell.com/2009/12/script-club-coming-to-the-greater-milwaukee-area/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Steven Murawski</name>
						<uri>http://www.usepowershell.com</uri>
					</author>
		<title type="html"><![CDATA[Using the Sync Framework from PowerShell]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UsePowershell/~3/VCA7sHWAaGw/" />
		<id>http://blog.usepowershell.com/2009/11/using-the-sync-framework-from-powershell/</id>
		<updated>2010-01-21T20:30:27Z</updated>
		<published>2009-11-13T14:11:50Z</published>
		<category scheme="http://blog.usepowershell.com" term=".NET Framework" /><category scheme="http://blog.usepowershell.com" term="PowerShell" /><category scheme="http://blog.usepowershell.com" term="PowerShell Version 2" /><category scheme="http://blog.usepowershell.com" term="Scripts" /><category scheme="http://blog.usepowershell.com" term="Sync Framework" />		<summary type="html"><![CDATA[I’ve been exploring the Sync Framework for use in a couple of projects I have going and PowerShell is my preferred exploratory environment. It was a bit of fun, since I got to work with eventing for the first time in V2. First, I downloaded the Sync Framework Software Development Kit.  That provided me with [...]]]></summary>
		<content type="html" xml:base="http://blog.usepowershell.com/2009/11/using-the-sync-framework-from-powershell/">&lt;p&gt;I’ve been exploring the &lt;a href="http://msdn.microsoft.com/en-us/sync/default.aspx" target="_blank"&gt;Sync Framework&lt;/a&gt; for use in a couple of projects I have going and &lt;a href="http://msdn.microsoft.com/en-us/library/ms714418(VS.85).aspx" target="_blank"&gt;PowerShell&lt;/a&gt; is my preferred exploratory environment.&lt;/p&gt;
&lt;p&gt;It was a bit of fun, since I got to work with eventing for the first time in V2.&lt;/p&gt;
&lt;p&gt;First, I downloaded the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=89adbb1e-53ff-41b5-ba17-8e43a2e66254&amp;amp;displaylang=en" target="_blank"&gt;Sync Framework Software Development Kit&lt;/a&gt;.  That provided me with the Sync Framework runtime as well as some documentation.&lt;/p&gt;
&lt;p&gt;The easiest way for me to get started was to take one &lt;a href="http://msdn.microsoft.com/en-us/library/ee617386(SQL.105).aspx" target="_blank"&gt;of the samples&lt;/a&gt; and convert that to PowerShell.&lt;/p&gt;
&lt;p&gt;I’m going to walk along the MSDN Sample and provide the equivalent PowerShell, as well as any changes I made to make it feel more PowerShell-y.&lt;/p&gt;
&lt;h3&gt;Setting Synchronization Options&lt;/h3&gt;
&lt;p&gt;We are working with the File Sync Provider First up is setting the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.synchronization.files.filesyncoptions(SQL.105).aspx" target="_blank"&gt;FileSyncOptions&lt;/a&gt;.  FileSyncOptions are an enumeration (a limited list defined in code that maps to certain values) whose values are controlled by setting the appropriate bits to indicate the presence or absence of a flag.  &lt;a href="http://twitter.com/meson3902" target="_blank"&gt;Mark Schill&lt;/a&gt; has &lt;a href="http://www.cmschill.net/stringtheory/2009/05/02/bitwise-operators/" target="_blank"&gt;a great post about how to set bitwise operations&lt;/a&gt;.&lt;/p&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #ff4500"&gt;$options &lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;= &lt;/span&gt;&lt;span style="color: #008080"&gt;[Microsoft.Synchronization.Files.FileSyncOptions]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;ExplicitDetectChanges&lt;/span&gt;
&lt;span style="color: #ff4500"&gt;$options&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-bor&lt;/span&gt; &lt;span style="color: #008080"&gt;[Microsoft.Synchronization.Files.FileSyncOptions]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;RecycleDeletedFiles&lt;/span&gt;
&lt;span style="color: #ff4500"&gt;$options&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-bor&lt;/span&gt; &lt;span style="color: #008080"&gt;[Microsoft.Synchronization.Files.FileSyncOptions]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;RecyclePreviousFileOnUpdates&lt;/span&gt;
&lt;span style="color: #ff4500"&gt;$options&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-bor&lt;/span&gt; &lt;span style="color: #008080"&gt;[Microsoft.Synchronization.Files.FileSyncOptions]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;RecycleConflictLoserFiles&lt;/span&gt;&lt;/pre&gt;
&lt;h3&gt;Specifying a Static Filter&lt;/h3&gt;
&lt;p&gt;With the &lt;a href="http://msdn.microsoft.com/en-us/library/bb902860(SQL.105).aspx" target="_blank"&gt;File System provider,&lt;/a&gt; we can provide filters to include or exclude files and directories.&lt;/p&gt;
&lt;p&gt;$FileNameFilter and $SubdirectoryNameFilter are parameters that take strings or string arrays.&lt;/p&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New-Object&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Microsoft.Synchronization.Files.FileSyncScopeFilter&lt;/span&gt;
&lt;span style="color: #00008b"&gt;if&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$FileNameFilter&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;count&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-gt&lt;/span&gt; &lt;span style="color: #800080"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
&lt;span style="color: #000000"&gt;{&lt;/span&gt;
   &lt;span style="color: #ff4500"&gt;$FileNameFilter&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff"&gt;ForEach-Object&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;FileNameExcludes&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Add&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$_&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt; &lt;span style="color: #000000"&gt;}&lt;/span&gt;
&lt;span style="color: #000000"&gt;}&lt;/span&gt;
&lt;span style="color: #00008b"&gt;if&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$SubdirectoryNameFilter&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;count&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-gt&lt;/span&gt; &lt;span style="color: #800080"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
&lt;span style="color: #000000"&gt;{&lt;/span&gt;
   &lt;span style="color: #ff4500"&gt;$SubdirectoryNameFilter&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff"&gt;ForEach-Object&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SubdirectoryExcludes&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Add&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$_&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt; &lt;span style="color: #000000"&gt;}&lt;/span&gt;
&lt;span style="color: #000000"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;h3&gt;Performing Change Detection&lt;/h3&gt;
&lt;p&gt;After configuring the filter, we examine the folders and files located at the paths specified.  If there has not been any previous synchronization, a metadata file will be created in each location to track any changes, updates, and deletes for later synchronization.&lt;/p&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #00008b"&gt;function&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Get-FileSystemChange&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
&lt;span style="color: #000000"&gt;{&lt;/span&gt;
    &lt;span style="color: #00008b"&gt;param&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$path&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
    &lt;span style="color: #00008b"&gt;try&lt;/span&gt;
    &lt;span style="color: #000000"&gt;{&lt;/span&gt;
        &lt;span style="color: #ff4500"&gt;$provider&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new-object&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Microsoft.Synchronization.Files.FileSyncProvider&lt;/span&gt; &lt;span style="color: #000080"&gt;-ArgumentList&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$path&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt;
        &lt;span style="color: #ff4500"&gt;$provider&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;DetectChanges&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
    &lt;span style="color: #000000"&gt;}&lt;/span&gt;
    &lt;span style="color: #00008b"&gt;finally&lt;/span&gt;
    &lt;span style="color: #000000"&gt;{&lt;/span&gt;
        &lt;span style="color: #00008b"&gt;if&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$provider&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-ne&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$null&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
        &lt;span style="color: #000000"&gt;{&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$provider&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Dispose&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
        &lt;span style="color: #000000"&gt;}&lt;/span&gt;
    &lt;span style="color: #000000"&gt;}&lt;/span&gt;
&lt;span style="color: #000000"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #0000ff"&gt;Get-FileSystemChange&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$SourcePath&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;Get-FileSystemChange&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$DestinationPath&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h3&gt;Handling Conflicts&lt;/h3&gt;
&lt;p&gt;Conflict resolution in the Sync Framework happens at the at the event level.  An event is merely something that happens that can trigger other actions.  Using &lt;a href="http://technet.microsoft.com/en-us/library/dd347672.aspx" target="_blank"&gt;Register-ObjectEvent&lt;/a&gt;, we can associate one or more scriptblocks with an event.&lt;/p&gt;
&lt;p&gt;First, I defined scriptblocks to handle the conflicts.  There is an enumeration, the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.synchronization.conflictresolutionaction(SQL.105).aspx" target="_blank"&gt;ConflictResolutionAction&lt;/a&gt; enumeration, that provides some options for dealing with conflicts.  For this example, we are going to pick the source object as the winner for any conflicts.&lt;/p&gt;
&lt;p&gt;You will also notice another type of conflict defined, and that is a Constraint conflict.  That can occur when an object of the same name is added on both sides in between synchronizations.  The resolution options for these conflicts can be found in the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.synchronization.constraintconflictresolutionaction(SQL.105).aspx" target="_blank"&gt;ConstraintConflictResolutionAction&lt;/a&gt; enumeration.&lt;/p&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #ff4500"&gt;$ItemConflictAction&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt;   &lt;span style="color: #000000"&gt;{&lt;/span&gt;
    &lt;span style="color: #ff4500"&gt;$event&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceEventArgs&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SetResolutionAction&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #008080"&gt;[Microsoft.Synchronization.ConflictResolutionAction]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceWins&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
    &lt;span style="color: #008080"&gt;[string[]]&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$global:FileSyncReport&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Conflicted&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$event&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceEventArgs&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;DestinationChange&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;ItemId&lt;/span&gt;
&lt;span style="color: #000000"&gt;}&lt;/span&gt;
&lt;span style="color: #ff4500"&gt;$ItemConstraintAction&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt;
     &lt;span style="color: #ff4500"&gt;$event&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceEventArgs&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SetResolutionAction&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #008080"&gt;[Microsoft.Synchronization.ConstraintConflictResolutionAction]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceWins&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
     &lt;span style="color: #008080"&gt;[string[]]&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$global:FileSyncReport&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Constrained&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$event&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceEventArgs&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;DestinationChange&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;ItemId&lt;/span&gt;
&lt;span style="color: #000000"&gt;}&lt;/span&gt;            

&lt;span style="color: #006400"&gt;# Configure the events for conflicts or constraints for the source and destination providers&lt;/span&gt;
&lt;span style="color: #ff4500"&gt;$destinationCallbacks&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$destinationProvider&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;DestinationCallbacks&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;Register-ObjectEvent&lt;/span&gt; &lt;span style="color: #000080"&gt;-InputObject&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$destinationCallbacks&lt;/span&gt; &lt;span style="color: #000080"&gt;-EventName&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;ItemConflicting&lt;/span&gt; &lt;span style="color: #000080"&gt;-Action&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$ItemConflictAction&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Out-Null&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;Register-ObjectEvent&lt;/span&gt; &lt;span style="color: #000080"&gt;-InputObject&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$destinationCallbacks&lt;/span&gt; &lt;span style="color: #000080"&gt;-EventName&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;ItemConstraint&lt;/span&gt; &lt;span style="color: #000080"&gt;-Action&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$ItemConstraintAction&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Out-Null&lt;/span&gt;            

&lt;span style="color: #ff4500"&gt;$sourceCallbacks&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$SourceProvider&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;DestinationCallbacks&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;Register-ObjectEvent&lt;/span&gt; &lt;span style="color: #000080"&gt;-InputObject&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$sourceCallbacks&lt;/span&gt; &lt;span style="color: #000080"&gt;-EventName&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;ItemConflicting&lt;/span&gt; &lt;span style="color: #000080"&gt;-Action&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$ItemConflictAction&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Out-Null&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;Register-ObjectEvent&lt;/span&gt; &lt;span style="color: #000080"&gt;-InputObject&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$sourceCallbacks&lt;/span&gt; &lt;span style="color: #000080"&gt;-EventName&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;ItemConstraint&lt;/span&gt; &lt;span style="color: #000080"&gt;-Action&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$ItemConstraintAction&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Out-Null&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;We also see for the first time in the script blocks a variable called $event.  This is an automatic variable exposed by the event and provides us information that we can use in our action.&lt;/p&gt;
&lt;p&gt;Finally, I’m updating a variable in the global scope.  There probably is a better way to handle this, but scriptblocks executed in response to events only have access to the global scope and any of the automatic variable exposed to it.  Therefore, I use a variable in the global scope to gather my reporting information.&lt;/p&gt;
&lt;h3&gt;Synchronizing Two Replicas&lt;/h3&gt;
&lt;p&gt;To start to synchronize the two sides, first we set up the synchronization via a &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.synchronization.syncorchestrator.aspx" target="_blank"&gt;SyncOrchestrator&lt;/a&gt; and assign it the local and remote providers, as well as defining the direction of the synchronization.  In this example (sticking with the format from MSDN, we will do an Upload, which is in the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.synchronization.syncdirectionorder.aspx" target="_blank"&gt;SyncDirectionOrder enumeration&lt;/a&gt; (other options are Download, DownloadAndUpload, and UploadAndDownload). &lt;/p&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400"&gt;# Create the agent that will perform the file sync&lt;/span&gt;
&lt;span style="color: #ff4500"&gt;$agent&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New-Object&lt;/span&gt;  &lt;span style="color: #8a2be2"&gt;Microsoft.Synchronization.SyncOrchestrator&lt;/span&gt;
&lt;span style="color: #ff4500"&gt;$agent&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;LocalProvider&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$sourceProvider&lt;/span&gt;
&lt;span style="color: #ff4500"&gt;$agent&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;RemoteProvider&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$destinationProvider&lt;/span&gt;            

&lt;span style="color: #006400"&gt;# Upload changes from the source to the destination.&lt;/span&gt;
&lt;span style="color: #ff4500"&gt;$agent&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Direction&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #008080"&gt;[Microsoft.Synchronization.SyncDirectionOrder]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;Upload&lt;/span&gt;            

&lt;span style="color: #0000ff"&gt;Write-Host&lt;/span&gt; &lt;span style="color: #8b0000"&gt;"Synchronizing changes from $($sourceProvider.RootDirectoryPath) to replica: $($destinationProvider.RootDirectoryPath)"&lt;/span&gt;
&lt;span style="color: #ff4500"&gt;$agent&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Synchronize&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;span style="color: #000000"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;To achieve two way synchronization, we will do the upload twice, reversing the order of the providers.&lt;/p&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #0000ff"&gt;Invoke-OneWayFileSync&lt;/span&gt; &lt;span style="color: #000080"&gt;-SourcePath&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$SourcePath&lt;/span&gt; &lt;span style="color: #000080"&gt;-DestinationPath&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$DestinationPath&lt;/span&gt; &lt;span style="color: #000080"&gt;-Filter&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$null&lt;/span&gt; &lt;span style="color: #000080"&gt;-Options&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;Invoke-OneWayFileSync&lt;/span&gt; &lt;span style="color: #000080"&gt;-SourcePath&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$DestinationPath&lt;/span&gt; &lt;span style="color: #000080"&gt;-DestinationPath&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$SourcePath&lt;/span&gt; &lt;span style="color: #000080"&gt;-Filter&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$null&lt;/span&gt; &lt;span style="color: #000080"&gt;-Options&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt;&lt;/pre&gt;
&lt;h3&gt;Full Example&lt;/h3&gt;
&lt;p&gt;I modified the example to write out a custom object (and the logging is in the variable in the global scope as noted in the Handling Conflicts section) with the results of the synchronization (rather than logging it to the console).&lt;/p&gt;
&lt;p&gt;In all, my translation is pretty similar to the example code, but there are some differences. &lt;/p&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #006400"&gt;# Requires -Version 2&lt;/span&gt;
&lt;span style="color: #006400"&gt;# Also depends on having the Microsoft Sync Framework 2.0 SDK or Runtime&lt;/span&gt;
&lt;span style="color: #006400"&gt;# --SDK--&lt;/span&gt;
&lt;span style="color: #006400"&gt;# http://www.microsoft.com/downloads/details.aspx?FamilyID=89adbb1e-53ff-41b5-ba17-8e43a2e66254&amp;amp;displaylang=en&lt;/span&gt;
&lt;span style="color: #006400"&gt;# --Runtime--&lt;/span&gt;
&lt;span style="color: #006400"&gt;# http://www.microsoft.com/downloads/details.aspx?FamilyId=109DB36E-CDD0-4514-9FB5-B77D9CEA37F6&amp;amp;displaylang=en&lt;/span&gt;
&lt;span style="color: #006400"&gt;#&lt;/span&gt;
&lt;span style="color: #006400"&gt;#&lt;/span&gt;            

&lt;span style="color: #a9a9a9"&gt;[&lt;/span&gt;&lt;span style="color: #add8e6"&gt;CmdletBinding&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;SupportsShouldProcess&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$true&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;]&lt;/span&gt;
&lt;span style="color: #00008b"&gt;param&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;
    &lt;span style="color: #a9a9a9"&gt;[&lt;/span&gt;&lt;span style="color: #add8e6"&gt;Parameter&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;Position&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt;&lt;span style="color: #800080"&gt;1&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #000000"&gt;Mandatory&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$true&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #000000"&gt;ValueFromPipelineByPropertyName&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$true&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;]&lt;/span&gt;
    &lt;span style="color: #a9a9a9"&gt;[&lt;/span&gt;&lt;span style="color: #add8e6"&gt;Alias&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #8b0000"&gt;'FullName'&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #8b0000"&gt;'Path'&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;]&lt;/span&gt;
    &lt;span style="color: #008080"&gt;[string]&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$SourcePath&lt;/span&gt;
    &lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;[&lt;/span&gt;&lt;span style="color: #add8e6"&gt;Parameter&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;Position&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt;&lt;span style="color: #800080"&gt;2&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #000000"&gt;Mandatory&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$true&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;]&lt;/span&gt;
    &lt;span style="color: #008080"&gt;[string]&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$DestinationPath&lt;/span&gt;
    &lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;[&lt;/span&gt;&lt;span style="color: #add8e6"&gt;Parameter&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;Position&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt;&lt;span style="color: #800080"&gt;3&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;]&lt;/span&gt;
    &lt;span style="color: #008080"&gt;[string[]]&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$FileNameFilter&lt;/span&gt;
    &lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;[&lt;/span&gt;&lt;span style="color: #add8e6"&gt;Parameter&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;Position&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt;&lt;span style="color: #800080"&gt;4&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;]&lt;/span&gt;
    &lt;span style="color: #008080"&gt;[string[]]&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$SubdirectoryNameFilter&lt;/span&gt;
&lt;span style="color: #000000"&gt;)&lt;/span&gt;
&lt;span style="color: #006400"&gt;&amp;lt;#
    .Synopsis
        Synchronizes to directory trees
    .Description
        Examines two directory structures (SourcePath and DestinationPath) and uses the Microsoft Sync Framework
        File System Provider to synchronize them.
    .Example
        An example of using the command
#&amp;gt;&lt;/span&gt;
&lt;span style="color: #00008b"&gt;begin&lt;/span&gt;
&lt;span style="color: #000000"&gt;{&lt;/span&gt;
    &lt;span style="color: #008080"&gt;[reflection.assembly]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;LoadWithPartialName&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #8b0000"&gt;'Microsoft.Synchronization'&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Out-Null&lt;/span&gt;
    &lt;span style="color: #008080"&gt;[reflection.assembly]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;LoadWithPartialName&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #8b0000"&gt;'Microsoft.Synchronization.Files'&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Out-Null&lt;/span&gt;            

    &lt;span style="color: #00008b"&gt;function&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Get-FileSystemChange&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
    &lt;span style="color: #000000"&gt;{&lt;/span&gt;
        &lt;span style="color: #00008b"&gt;param&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$path&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
        &lt;span style="color: #00008b"&gt;try&lt;/span&gt;
        &lt;span style="color: #000000"&gt;{&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$provider&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new-object&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Microsoft.Synchronization.Files.FileSyncProvider&lt;/span&gt; &lt;span style="color: #000080"&gt;-ArgumentList&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$path&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$provider&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;DetectChanges&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
        &lt;span style="color: #000000"&gt;}&lt;/span&gt;
        &lt;span style="color: #00008b"&gt;finally&lt;/span&gt;
        &lt;span style="color: #000000"&gt;{&lt;/span&gt;
            &lt;span style="color: #00008b"&gt;if&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$provider&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-ne&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$null&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
            &lt;span style="color: #000000"&gt;{&lt;/span&gt;
                &lt;span style="color: #ff4500"&gt;$provider&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Dispose&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
            &lt;span style="color: #000000"&gt;}&lt;/span&gt;
        &lt;span style="color: #000000"&gt;}&lt;/span&gt;
    &lt;span style="color: #000000"&gt;}&lt;/span&gt;            

    &lt;span style="color: #00008b"&gt;function&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Invoke-OneWayFileSync&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
    &lt;span style="color: #000000"&gt;{&lt;/span&gt;
        &lt;span style="color: #00008b"&gt;param&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$SourcePath&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$DestinationPath&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt;
                    &lt;span style="color: #ff4500"&gt;$Filter&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$Options&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
        &lt;span style="color: #ff4500"&gt;$ApplyChangeJobs&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #000000"&gt;@(&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
        &lt;span style="color: #ff4500"&gt;$AppliedChangeJobs&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #000000"&gt;@(&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
        &lt;span style="color: #00008b"&gt;try&lt;/span&gt;
        &lt;span style="color: #000000"&gt;{&lt;/span&gt;
            &lt;span style="color: #006400"&gt;# Scriptblocks to handle the events raised during synchronization&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$AppliedChangeAction&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt;
                &lt;span style="color: #ff4500"&gt;$argument&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$event&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceEventArgs&lt;/span&gt;
                &lt;span style="color: #00008b"&gt;switch&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$argument&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;ChangeType&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
                &lt;span style="color: #000000"&gt;{&lt;/span&gt;
                    &lt;span style="color: #000000"&gt;{&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$argument&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;ChangeType&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-eq&lt;/span&gt; &lt;span style="color: #008080"&gt;[Microsoft.Synchronization.Files.ChangeType]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;Create&lt;/span&gt; &lt;span style="color: #000000"&gt;}&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt;&lt;span style="color: #008080"&gt;[string[]]&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$global:FileSyncReport&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Created&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$argument&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;NewFilePath&lt;/span&gt;&lt;span style="color: #000000"&gt;}&lt;/span&gt;
                    &lt;span style="color: #000000"&gt;{&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$argument&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;ChangeType&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-eq&lt;/span&gt; &lt;span style="color: #008080"&gt;[Microsoft.Synchronization.Files.ChangeType]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;Delete&lt;/span&gt; &lt;span style="color: #000000"&gt;}&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt;&lt;span style="color: #008080"&gt;[string[]]&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$global:FileSyncReport&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Deleted&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$argument&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;OldFilePath&lt;/span&gt;&lt;span style="color: #000000"&gt;}&lt;/span&gt;
                    &lt;span style="color: #000000"&gt;{&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$argument&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;ChangeType&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-eq&lt;/span&gt; &lt;span style="color: #008080"&gt;[Microsoft.Synchronization.Files.ChangeType]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;Update&lt;/span&gt; &lt;span style="color: #000000"&gt;}&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt;&lt;span style="color: #008080"&gt;[string[]]&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$global:FileSyncReport&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Updated&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$argument&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;OldFilePath&lt;/span&gt;&lt;span style="color: #000000"&gt;}&lt;/span&gt;
                    &lt;span style="color: #000000"&gt;{&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$argument&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;ChangeType&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-eq&lt;/span&gt; &lt;span style="color: #008080"&gt;[Microsoft.Synchronization.Files.ChangeType]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;Rename&lt;/span&gt; &lt;span style="color: #000000"&gt;}&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt;&lt;span style="color: #008080"&gt;[string[]]&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$global:FileSyncReport&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Renamed&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$argument&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;OldFilePath&lt;/span&gt;&lt;span style="color: #000000"&gt;}&lt;/span&gt;
                &lt;span style="color: #000000"&gt;}&lt;/span&gt;
            &lt;span style="color: #000000"&gt;}&lt;/span&gt;            

            &lt;span style="color: #ff4500"&gt;$SkippedChangeAction&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt;
                &lt;span style="color: #008080"&gt;[string[]]&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$global:FileSyncReport&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Skipped&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$event&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceEventArgs&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;CurrentFilePath&lt;/span&gt;            

                &lt;span style="color: #00008b"&gt;if&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$event&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceEventArgs&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Exception&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-ne&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$null&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
                &lt;span style="color: #000000"&gt;{&lt;/span&gt;
                    &lt;span style="color: #0000ff"&gt;Write-Error&lt;/span&gt; &lt;span style="color: #8b0000"&gt;'['&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;+&lt;/span&gt; &lt;span style="color: #8b0000"&gt;"$($event.SourceEventArgs.Exception.Message)"&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;+']'&lt;/span&gt;
                &lt;span style="color: #000000"&gt;}&lt;/span&gt;
            &lt;span style="color: #000000"&gt;}&lt;/span&gt;            

            &lt;span style="color: #006400"&gt;# Create source provider and register change events for it&lt;/span&gt;            

            &lt;span style="color: #ff4500"&gt;$sourceProvider&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New-Object&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Microsoft.Synchronization.Files.FileSyncProvider&lt;/span&gt; &lt;span style="color: #000080"&gt;-ArgumentList&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$SourcePath&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$AppliedChangeJobs&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Register-ObjectEvent&lt;/span&gt; &lt;span style="color: #000080"&gt;-InputObject&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$SourceProvider&lt;/span&gt; &lt;span style="color: #000080"&gt;-EventName&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;AppliedChange&lt;/span&gt; &lt;span style="color: #000080"&gt;-Action&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$AppliedChangeAction&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$AppliedChangeJobs&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Register-ObjectEvent&lt;/span&gt; &lt;span style="color: #000080"&gt;-InputObject&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$SourceProvider&lt;/span&gt; &lt;span style="color: #000080"&gt;-EventName&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;SkippedChange&lt;/span&gt; &lt;span style="color: #000080"&gt;-Action&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$SkippedChangeAction&lt;/span&gt;             

            &lt;span style="color: #ff4500"&gt;$ApplyChangeJobs&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$SourceApplyChangeJob&lt;/span&gt;            

            &lt;span style="color: #006400"&gt;# Create destination provider and register change events for it&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$destinationProvider&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New-Object&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Microsoft.Synchronization.Files.FileSyncProvider&lt;/span&gt; &lt;span style="color: #000080"&gt;-ArgumentList&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$DestinationPath&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$AppliedChangeJobs&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Register-ObjectEvent&lt;/span&gt; &lt;span style="color: #000080"&gt;-InputObject&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$destinationProvider&lt;/span&gt; &lt;span style="color: #000080"&gt;-EventName&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;AppliedChange&lt;/span&gt; &lt;span style="color: #000080"&gt;-Action&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$AppliedChangeAction&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$AppliedChangeJobs&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Register-ObjectEvent&lt;/span&gt; &lt;span style="color: #000080"&gt;-InputObject&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$destinationProvider&lt;/span&gt; &lt;span style="color: #000080"&gt;-EventName&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;SkippedChange&lt;/span&gt; &lt;span style="color: #000080"&gt;-Action&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$SkippedChangeAction&lt;/span&gt;            

            &lt;span style="color: #ff4500"&gt;$ApplyChangeJobs&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$DestApplyChangeJob&lt;/span&gt;            

            &lt;span style="color: #006400"&gt;# Use scriptblocks for the SyncCallbacks for conflicting items.&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$ItemConflictAction&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt;   &lt;span style="color: #000000"&gt;{&lt;/span&gt;
                &lt;span style="color: #ff4500"&gt;$event&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceEventArgs&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SetResolutionAction&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #008080"&gt;[Microsoft.Synchronization.ConflictResolutionAction]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceWins&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
                &lt;span style="color: #008080"&gt;[string[]]&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$global:FileSyncReport&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Conflicted&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$event&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceEventArgs&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;DestinationChange&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;ItemId&lt;/span&gt;
            &lt;span style="color: #000000"&gt;}&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$ItemConstraintAction&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt;
                &lt;span style="color: #ff4500"&gt;$event&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceEventArgs&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SetResolutionAction&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #008080"&gt;[Microsoft.Synchronization.ConstraintConflictResolutionAction]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceWins&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
                &lt;span style="color: #008080"&gt;[string[]]&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$global:FileSyncReport&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Constrained&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$event&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceEventArgs&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;DestinationChange&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;ItemId&lt;/span&gt;
            &lt;span style="color: #000000"&gt;}&lt;/span&gt;            

            &lt;span style="color: #006400"&gt;#Configure the events for conflicts or constraints for the source and destination providers&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$destinationCallbacks&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$destinationProvider&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;DestinationCallbacks&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$AppliedChangeJobs&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Register-ObjectEvent&lt;/span&gt; &lt;span style="color: #000080"&gt;-InputObject&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$destinationCallbacks&lt;/span&gt; &lt;span style="color: #000080"&gt;-EventName&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;ItemConflicting&lt;/span&gt; &lt;span style="color: #000080"&gt;-Action&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$ItemConflictAction&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$AppliedChangeJobs&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Register-ObjectEvent&lt;/span&gt; &lt;span style="color: #000080"&gt;-InputObject&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$destinationCallbacks&lt;/span&gt; &lt;span style="color: #000080"&gt;-EventName&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;ItemConstraint&lt;/span&gt; &lt;span style="color: #000080"&gt;-Action&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$ItemConstraintAction&lt;/span&gt;             

            &lt;span style="color: #ff4500"&gt;$sourceCallbacks&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$SourceProvider&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;DestinationCallbacks&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$AppliedChangeJobs&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Register-ObjectEvent&lt;/span&gt; &lt;span style="color: #000080"&gt;-InputObject&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$sourceCallbacks&lt;/span&gt; &lt;span style="color: #000080"&gt;-EventName&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;ItemConflicting&lt;/span&gt; &lt;span style="color: #000080"&gt;-Action&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$ItemConflictAction&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$AppliedChangeJobs&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;+=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Register-ObjectEvent&lt;/span&gt; &lt;span style="color: #000080"&gt;-InputObject&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$sourceCallbacks&lt;/span&gt; &lt;span style="color: #000080"&gt;-EventName&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;ItemConstraint&lt;/span&gt; &lt;span style="color: #000080"&gt;-Action&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$ItemConstraintAction&lt;/span&gt;             

            &lt;span style="color: #006400"&gt;# Create the agent that will perform the file sync&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$agent&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New-Object&lt;/span&gt;  &lt;span style="color: #8a2be2"&gt;Microsoft.Synchronization.SyncOrchestrator&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$agent&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;LocalProvider&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$sourceProvider&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$agent&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;RemoteProvider&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$destinationProvider&lt;/span&gt;            

            &lt;span style="color: #006400"&gt;# Upload changes from the source to the destination.&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$agent&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Direction&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #008080"&gt;[Microsoft.Synchronization.SyncDirectionOrder]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;Upload&lt;/span&gt;            

            &lt;span style="color: #0000ff"&gt;Write-Host&lt;/span&gt; &lt;span style="color: #8b0000"&gt;"Synchronizing changes from $($sourceProvider.RootDirectoryPath) to replica: $($destinationProvider.RootDirectoryPath)"&lt;/span&gt;
            &lt;span style="color: #ff4500"&gt;$agent&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Synchronize&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;span style="color: #000000"&gt;;&lt;/span&gt;
        &lt;span style="color: #000000"&gt;}&lt;/span&gt;
        &lt;span style="color: #00008b"&gt;finally&lt;/span&gt;
        &lt;span style="color: #000000"&gt;{&lt;/span&gt;
            &lt;span style="color: #006400"&gt;# Release resources.&lt;/span&gt;
            &lt;span style="color: #00008b"&gt;if&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$sourceProvider&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-ne&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$null&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$sourceProvider&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Dispose&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;span style="color: #000000"&gt;}&lt;/span&gt;
            &lt;span style="color: #00008b"&gt;if&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$destinationProvider&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-ne&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$null&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$destinationProvider&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Dispose&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;span style="color: #000000"&gt;}&lt;/span&gt;
        &lt;span style="color: #000000"&gt;}&lt;/span&gt;
    &lt;span style="color: #000000"&gt;}&lt;/span&gt;            

    &lt;span style="color: #006400"&gt;# Set options for the synchronization session. In this case, options specify&lt;/span&gt;
    &lt;span style="color: #006400"&gt;# that the application will explicitly call FileSyncProvider.DetectChanges, and&lt;/span&gt;
    &lt;span style="color: #006400"&gt;# that items should be moved to the Recycle Bin instead of being permanently deleted.&lt;/span&gt;            

    &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #008080"&gt;[Microsoft.Synchronization.Files.FileSyncOptions]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;ExplicitDetectChanges&lt;/span&gt;
    &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-bor&lt;/span&gt; &lt;span style="color: #008080"&gt;[Microsoft.Synchronization.Files.FileSyncOptions]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;RecycleDeletedFiles&lt;/span&gt;
    &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-bor&lt;/span&gt; &lt;span style="color: #008080"&gt;[Microsoft.Synchronization.Files.FileSyncOptions]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;RecyclePreviousFileOnUpdates&lt;/span&gt;
    &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-bor&lt;/span&gt; &lt;span style="color: #008080"&gt;[Microsoft.Synchronization.Files.FileSyncOptions]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;RecycleConflictLoserFiles&lt;/span&gt;
&lt;span style="color: #000000"&gt;}&lt;/span&gt;
&lt;span style="color: #00008b"&gt;process&lt;/span&gt;
&lt;span style="color: #000000"&gt;{&lt;/span&gt;
    &lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New-Object&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Microsoft.Synchronization.Files.FileSyncScopeFilter&lt;/span&gt;
    &lt;span style="color: #00008b"&gt;if&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$FileNameFilter&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;count&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-gt&lt;/span&gt; &lt;span style="color: #800080"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
    &lt;span style="color: #000000"&gt;{&lt;/span&gt;
       &lt;span style="color: #ff4500"&gt;$FileNameFilter&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff"&gt;ForEach-Object&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;FileNameExcludes&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Add&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$_&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt; &lt;span style="color: #000000"&gt;}&lt;/span&gt;
    &lt;span style="color: #000000"&gt;}&lt;/span&gt;
    &lt;span style="color: #00008b"&gt;if&lt;/span&gt; &lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$SubdirectoryNameFilter&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;count&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;-gt&lt;/span&gt; &lt;span style="color: #800080"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
    &lt;span style="color: #000000"&gt;{&lt;/span&gt;
       &lt;span style="color: #ff4500"&gt;$SubdirectoryNameFilter&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff"&gt;ForEach-Object&lt;/span&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SubdirectoryExcludes&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Add&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$_&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt; &lt;span style="color: #000000"&gt;}&lt;/span&gt;
    &lt;span style="color: #000000"&gt;}&lt;/span&gt;            

    &lt;span style="color: #006400"&gt;# Perform the detect changes operation on the two file locations&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;Get-FileSystemChange&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$SourcePath&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;Get-FileSystemChange&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$DestinationPath&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$filter&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt;            

    &lt;span style="color: #006400"&gt;# Reporting Object - using the global scope so that it can be updated by the event scriptblocks.&lt;/span&gt;
    &lt;span style="color: #ff4500"&gt;$global:FileSyncReport&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New-Object&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;PSObject&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;|&lt;/span&gt;
        &lt;span style="color: #0000ff"&gt;Select-Object&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;SourceStats&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;DestinationStats&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Created&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Deleted&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Overwritten&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Renamed&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Skipped&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Conflicted&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;,&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Constrained&lt;/span&gt;            

    &lt;span style="color: #006400"&gt;# We don't need to pass any filters here, since we are using the file detection that was previously completed.&lt;/span&gt;
    &lt;span style="color: #006400"&gt;# this will only &lt;/span&gt;
    &lt;span style="color: #ff4500"&gt;$global:FileSyncReport&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;SourceStats&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Invoke-OneWayFileSync&lt;/span&gt; &lt;span style="color: #000080"&gt;-SourcePath&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$SourcePath&lt;/span&gt; &lt;span style="color: #000080"&gt;-DestinationPath&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$DestinationPath&lt;/span&gt; &lt;span style="color: #000080"&gt;-Filter&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$null&lt;/span&gt; &lt;span style="color: #000080"&gt;-Options&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt;
    &lt;span style="color: #ff4500"&gt;$global:FileSyncReport&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;DestinationStats&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Invoke-OneWayFileSync&lt;/span&gt; &lt;span style="color: #000080"&gt;-SourcePath&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$DestinationPath&lt;/span&gt; &lt;span style="color: #000080"&gt;-DestinationPath&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$SourcePath&lt;/span&gt; &lt;span style="color: #000080"&gt;-Filter&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$null&lt;/span&gt; &lt;span style="color: #000080"&gt;-Options&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$options&lt;/span&gt;            

    &lt;span style="color: #006400"&gt;# Write result to pipeline&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;Write-Output&lt;/span&gt; &lt;span style="color: #ff4500"&gt;$global:FileSyncReport&lt;/span&gt;
&lt;span style="color: #000000"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;h3 class="PowerShellColorizedScript"&gt;&lt;span style="color: #000000"&gt;&lt;a href="http://download.usepowershell.com/Invoke-SyncFrameworkSample.zip" target="_blank"&gt;Download Invoke-SyncFrameworkSample.zip&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/C2zpS-18bMWK5esbwGRdauOGuow/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/C2zpS-18bMWK5esbwGRdauOGuow/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/C2zpS-18bMWK5esbwGRdauOGuow/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/C2zpS-18bMWK5esbwGRdauOGuow/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/UsePowershell?a=VCA7sHWAaGw:IHFaeMicKsM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/UsePowershell?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/UsePowershell/~4/VCA7sHWAaGw" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://blog.usepowershell.com/2009/11/using-the-sync-framework-from-powershell/#comments" thr:count="11" />
		<link rel="replies" type="application/atom+xml" href="http://blog.usepowershell.com/2009/11/using-the-sync-framework-from-powershell/feed/atom/" thr:count="11" />
		<thr:total>11</thr:total>
	<feedburner:origLink>http://blog.usepowershell.com/2009/11/using-the-sync-framework-from-powershell/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Steven Murawski</name>
						<uri>http://www.usepowershell.com</uri>
					</author>
		<title type="html"><![CDATA[So Easy, I Could Kick Myself]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UsePowershell/~3/gF4cZMg1b28/" />
		<id>http://blog.usepowershell.com/2009/11/so-easy-i-could-kick-myself/</id>
		<updated>2010-01-07T22:18:29Z</updated>
		<published>2009-11-12T21:24:00Z</published>
		<category scheme="http://blog.usepowershell.com" term="Crystal Reports" /><category scheme="http://blog.usepowershell.com" term="PowerShell" /><category scheme="http://blog.usepowershell.com" term="PowerShell Version 2" /><category scheme="http://blog.usepowershell.com" term="Scripts" />		<summary type="html"><![CDATA[I’m updating Crystal Reports and trying to determine which reports might have been affected by some schema changes or functional changes in how the data was being stored.  The problem I’ve had is that when there are a large number of reports, it is very time consuming to open each one, look at it, and [...]]]></summary>
		<content type="html" xml:base="http://blog.usepowershell.com/2009/11/so-easy-i-could-kick-myself/">&lt;p&gt;I’m updating Crystal Reports and trying to determine which reports might have been affected by some schema changes or functional changes in how the data was being stored. &lt;/p&gt;
&lt;p&gt;The problem I’ve had is that when there are a large number of reports, it is very time consuming to open each one, look at it, and see if it contains any affected tables or views.&lt;/p&gt;
&lt;p&gt;I’ve had to deal with this in my previous role as well.  After feeling the pain a few times, I turned my intern loose on the problem and shelved the problem as “just another pain in dealing with Crystal Reports”.&lt;/p&gt;
&lt;p&gt;Now, I’m back dealing with Crystal Reports more frequently and in the position to have to possibly update around 30 or 40 reports that were written before I started.&lt;/p&gt;
&lt;p&gt;I’ve recently had a bit of exposure to the object model for the &lt;a href="http://msdn.microsoft.com/en-us/library/bb944221.aspx" target="_blank"&gt;.NET API for Crystal Reports&lt;/a&gt; and thought maybe I could leverage that through &lt;a href="http://msdn.microsoft.com/en-us/library/ms714418(VS.85).aspx" target="_blank"&gt;PowerShell&lt;/a&gt; and whip together a quick script to help me list out the tables in each report.&lt;/p&gt;
&lt;p&gt;It turned out to be painfully easy… &lt;/p&gt;
&lt;pre class="PowerShellColorizedScript"&gt;&lt;span style="color: #008080"&gt;[reflection.assembly]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;LoadWithPartialName&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #8b0000"&gt;'CrystalDecisions.Shared'&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
&lt;span style="color: #008080"&gt;[reflection.assembly]&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;::&lt;/span&gt;&lt;span style="color: #000000"&gt;LoadWithPartialName&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #8b0000"&gt;'CrystalDecisions.CrystalReports.Engine'&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
&lt;span style="color: #ff4500"&gt;$report&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New-Object&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;CrystalDecisions.CrystalReports.Engine.ReportDocument&lt;/span&gt;
&lt;span style="color: #ff4500"&gt;$report&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;load&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #ff4500"&gt;$pathToScript&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;
&lt;span style="color: #ff4500"&gt;$report&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Database&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Tables&lt;/span&gt; &lt;span style="color: #a9a9a9"&gt;|&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Select-Object&lt;/span&gt; &lt;span style="color: #000080"&gt;-expand&lt;/span&gt; &lt;span style="color: #8a2be2"&gt;Name&lt;/span&gt;
&lt;span style="color: #ff4500"&gt;$report&lt;/span&gt;&lt;span style="color: #a9a9a9"&gt;.&lt;/span&gt;&lt;span style="color: #000000"&gt;Dispose&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;After I got the basics, I poked around and updated the script further (&lt;a href="http://poshcode.org/1471" target="_blank"&gt;and posted it on PoshCode&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The full script also accesses the first level of subreports and retrieves their tables as well.&lt;/p&gt;
&lt;p&gt;NOTE: &lt;a href="http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=56787567" target="_blank"&gt;Requires either the Crystal Report Runtime (Visual Studio 2008) &lt;/a&gt; or Visual Studio to be installed.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="http://download.usepowershell.com/get-crystalreporttable.ps1"&gt;DOWNLOAD UPDATED SCRIPT &lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/WE45PI0vBJhtvMuiqSCvv0WgiRQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WE45PI0vBJhtvMuiqSCvv0WgiRQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/WE45PI0vBJhtvMuiqSCvv0WgiRQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WE45PI0vBJhtvMuiqSCvv0WgiRQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/UsePowershell?a=gF4cZMg1b28:d16QCTa18AI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/UsePowershell?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/UsePowershell/~4/gF4cZMg1b28" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://blog.usepowershell.com/2009/11/so-easy-i-could-kick-myself/#comments" thr:count="3" />
		<link rel="replies" type="application/atom+xml" href="http://blog.usepowershell.com/2009/11/so-easy-i-could-kick-myself/feed/atom/" thr:count="3" />
		<thr:total>3</thr:total>
	<feedburner:origLink>http://blog.usepowershell.com/2009/11/so-easy-i-could-kick-myself/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Steven Murawski</name>
						<uri>http://www.usepowershell.com</uri>
					</author>
		<title type="html"><![CDATA[All Sorts of New]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UsePowershell/~3/vMnnBi8yBtc/" />
		<id>http://blog.usepowershell.com/2009/11/all-sorts-of-new/</id>
		<updated>2009-11-12T13:00:00Z</updated>
		<published>2009-11-12T13:00:00Z</published>
		<category scheme="http://blog.usepowershell.com" term="General" />		<summary type="html"><![CDATA[A lot has happened since I last had the opportunity to post.&#160; Quick recap: PowerShell v2 is now out and available for XP, Server 2003, Vista, Server 2008, and installed and on by default for Windows 7 and Server 2008 R2 SharePoint 2010 has an insane number (492) There is an open source cmdlet and [...]]]></summary>
		<content type="html" xml:base="http://blog.usepowershell.com/2009/11/all-sorts-of-new/">&lt;p&gt;A lot has happened since I last had the opportunity to post.&amp;#160; &lt;/p&gt;
&lt;p&gt;Quick recap:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://blogs.msdn.com/powershell/archive/2009/10/22/tonight-is-the-virtual-launch-party-powerscripting-podcast.aspx" target="_blank"&gt;PowerShell v2 is now out&lt;/a&gt; and available for &lt;a href="http://blogs.msdn.com/powershell/archive/2009/10/27/windows-management-framework-is-here.aspx" target="_blank"&gt;XP, Server 2003, Vista, Server 2008,&lt;/a&gt; and installed and on by default for Windows 7 and Server 2008 R2 &lt;/li&gt;
&lt;li&gt;SharePoint 2010 has an insane number (&lt;a href="http://dmitrysotnikov.wordpress.com/2009/10/19/sharepoint-2010-cmdlet-reference/" target="_blank"&gt;492&lt;/a&gt;) &lt;/li&gt;
&lt;li&gt;There is an &lt;a href="http://www.codeplex.com/CmdletDesigner" target="_blank"&gt;open source cmdlet and help designer&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://trypowershell.codeplex.com/" target="_blank"&gt;Try PowerShell&lt;/a&gt; is a great way to explore &lt;/li&gt;
&lt;li&gt;The &lt;a href="http://code.msdn.microsoft.com/PowerShellPack" target="_blank"&gt;PowershellPack&lt;/a&gt; provides some great modules that get you jump started with V2. &lt;/li&gt;
&lt;li&gt;&lt;a href="http://code.msdn.microsoft.com/azurecmdlets" target="_blank"&gt;Azure has cmdlets for management&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;There is introductory PowerShell material in the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c48b3eb4-ad4b-461c-9d5a-25f45d949b92&amp;amp;displaylang=en" target="_blank"&gt;Server 2008 R2 Developer Training Kit&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://channel9.msdn.com/learn/courses/WindowsServer2008R2/PowerShell/" target="_blank"&gt;There are some PowerShell for Developers training videos on Channel 9&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.jameskovacs.com/blog/ReleasingPsakeV100PsakeV200.aspx" target="_blank"&gt;James Kovacs released psake V2.00&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://pstfs.codeplex.com/" target="_blank"&gt;PsTFS has hit V1&lt;/a&gt; – which is great for me now.. &lt;/li&gt;
&lt;li&gt;I’m sure I’ve missed a ton of other cool &lt;a href="http://msdn.microsoft.com/en-us/library/ms714418(VS.85).aspx" target="_blank"&gt;PowerShell&lt;/a&gt; stuff that is happening too.. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And that leads me to what I’m doing now.&amp;#160; &lt;/p&gt;
&lt;p&gt;In August, I left my job as a IT Specialist for a municipal police department and took a job heading up research and development for &lt;a href="http://www.prophoenix.com" target="_blank"&gt;ProPhoenix&lt;/a&gt;, which is a software development company that make software for public safety agencies (police, fire, corrections, municipal courts).&lt;/p&gt;
&lt;p&gt;I now live in a more software development focused world and will get to spend more time focusing on using PowerShell to automate my current activities, explore new frameworks, and to build a management API for our applications.&amp;#160; I can’t wait to make PowerShell a requirement for our server products installation so I can get our support staff to start leveraging the capabilities PowerShell brings to the table.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/q73NYoQWFhBLwerVLlgVMSUYRGU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/q73NYoQWFhBLwerVLlgVMSUYRGU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/q73NYoQWFhBLwerVLlgVMSUYRGU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/q73NYoQWFhBLwerVLlgVMSUYRGU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/UsePowershell?a=vMnnBi8yBtc:k5mnJAJG_wg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/UsePowershell?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/UsePowershell/~4/vMnnBi8yBtc" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://blog.usepowershell.com/2009/11/all-sorts-of-new/#comments" thr:count="2" />
		<link rel="replies" type="application/atom+xml" href="http://blog.usepowershell.com/2009/11/all-sorts-of-new/feed/atom/" thr:count="2" />
		<thr:total>2</thr:total>
	<feedburner:origLink>http://blog.usepowershell.com/2009/11/all-sorts-of-new/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Steven Murawski</name>
						<uri>http://www.usepowershell.com</uri>
					</author>
		<title type="html"><![CDATA[PowerShell in Azure]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UsePowershell/~3/vqYjl7RbOy0/" />
		<id>http://blog.usepowershell.com/2009/07/powershell-in-azure/</id>
		<updated>2009-07-21T16:53:34Z</updated>
		<published>2009-07-21T16:53:34Z</published>
		<category scheme="http://blog.usepowershell.com" term="Azure" /><category scheme="http://blog.usepowershell.com" term="Development" /><category scheme="http://blog.usepowershell.com" term="PowerShell" />		<summary type="html"><![CDATA[The July CTP release of the Windows Azure SDK contains a new sample project called PowerShellRole which demonstrates that PowerShell is available in the cloud! Previous versions of the CTP have come with a sample Provider which you could use to access Azure storage (blobs, queues, and tables), but this actually provides demonstration of creating [...]]]></summary>
		<content type="html" xml:base="http://blog.usepowershell.com/2009/07/powershell-in-azure/">&lt;p&gt;The &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=aa40f3e2-afc5-484d-b4e9-6a5227e73590&amp;amp;displaylang=en" target="_blank"&gt;July CTP release of the Windows Azure SDK&lt;/a&gt; contains a new sample project called PowerShellRole which demonstrates that PowerShell is available in the cloud!&lt;/p&gt;
&lt;p&gt;Previous versions of the CTP have come with a sample Provider which you could use to access Azure storage (blobs, queues, and tables), but this actually provides demonstration of creating runspaces and executing pipelines in the cloud.&lt;/p&gt;
&lt;p&gt;Now to see what version is running in the cloud!&lt;/p&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/tVycZ-X9ExVKxHBD64nLA_-E8L0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tVycZ-X9ExVKxHBD64nLA_-E8L0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/tVycZ-X9ExVKxHBD64nLA_-E8L0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tVycZ-X9ExVKxHBD64nLA_-E8L0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/UsePowershell?a=vqYjl7RbOy0:rHwCUZf0txk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/UsePowershell?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/UsePowershell/~4/vqYjl7RbOy0" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://blog.usepowershell.com/2009/07/powershell-in-azure/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://blog.usepowershell.com/2009/07/powershell-in-azure/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://blog.usepowershell.com/2009/07/powershell-in-azure/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Steven Murawski</name>
						<uri>http://www.usepowershell.com</uri>
					</author>
		<title type="html"><![CDATA[Deep Dive: Error Handling &#8211; Error Types (part 1)]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UsePowershell/~3/vtnKbHP2fiI/" />
		<id>http://blog.usepowershell.com/2009/07/deep-dive-error-handling-error-types-part-1/</id>
		<updated>2009-11-20T19:12:55Z</updated>
		<published>2009-07-21T12:00:00Z</published>
		<category scheme="http://blog.usepowershell.com" term=".NET Framework" /><category scheme="http://blog.usepowershell.com" term="Base Class Libraries" /><category scheme="http://blog.usepowershell.com" term="Deep Dive" /><category scheme="http://blog.usepowershell.com" term="Error Handling" /><category scheme="http://blog.usepowershell.com" term="PowerShell Version 1" /><category scheme="http://blog.usepowershell.com" term="PowerShell Version 2" />		<summary type="html"><![CDATA[I started looking a little deeper at error handling in PowerShell after this StackOverflow question. PowerShell has two kinds of errors – terminating errors and non-terminating errors. Terminating errors are the errors that can stop command execution cold.  Non-terminating errors provided an additional challenge, as you need to be notified of failed operations and continue [...]]]></summary>
		<content type="html" xml:base="http://blog.usepowershell.com/2009/07/deep-dive-error-handling-error-types-part-1/">&lt;p&gt;I started looking a little deeper at error handling in PowerShell after &lt;a href="http://stackoverflow.com/questions/1142211/try-catch-does-not-seem-to-have-an-effect" target="_blank"&gt;this StackOverflow question&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;PowerShell has two kinds of errors – terminating errors and non-terminating errors.&lt;/p&gt;
&lt;p&gt;Terminating errors are the errors that can stop command execution cold.  Non-terminating errors provided an additional challenge, as you need to be notified of failed operations and continue with pipeline operations.  To deal with this issue and to provide additional output options, PowerShell employs the concept of streams.  There are three additional streams (other than the primary pipeline stream) available in PowerShell – Verbose, Warning, and Error (and .  We’ll be concerning ourselves with the output from the Error stream.&lt;/p&gt;
&lt;p&gt;There are some &lt;a href="http://technet.microsoft.com/en-us/library/dd347675.aspx" target="_blank"&gt;automatic variables&lt;/a&gt; in the shell that deal with errors as well.  $ErrorActionPreference is a variable that describes how PowerShell will treat non-terminating errors.  $ErrorActionPreference has four options: “Continue” (the default), “SilentlyContinue”, “Inquire”, and “Stop”.  $error is an array of all the errors that have occurred in the current session up to the number specified in $MaximumErrorCount.  $? is a boolean value that is $true if the previous operation succeeded and $false if it did not.&lt;/p&gt;
&lt;p&gt;PowerShell does have some built in flexibility to turn non-terminating errors into terminating errors.  Based on our setting of $ErrorActionPreference, PowerShell will treat a non-terminating error differently.  If $ErrorActionPreference is set to &amp;#8216;”Stop”, PowerShell will treat the errors from that scope and all sub scopes (unless explicitly overridden) as terminating errors.  If “Inquire” is chosen as the $ErrorActionPreference, then PowerShell will prompt the user at the console upon each error to ask whether it should continue (treat as non-terminating) or halt (treat as terminating), as well as providing an option to drop into a nested prompt.&lt;/p&gt;
&lt;p&gt;$ErrorActionPreference is a global preference that can be set, but the PowerShell runtime also allows more granular control by providing &lt;a href="http://technet.microsoft.com/en-us/library/dd315352.aspx" target="_blank"&gt;common parameters&lt;/a&gt; for -ErrorAction and -ErrorVariable (shorthand -EA and –EV) which allow you to determine per cmdlet (and in V2 per advanced function) how errors should be handled.  The –ErrorAction parameter takes the same options as $ErrorActionPreference.&lt;/p&gt;
&lt;p&gt;So what happens when you encounter an error?&lt;/p&gt;
&lt;p&gt;If you hit a terminating error, your script, function, or command will stop.  The error will be logged to the $error variable and written to the error stream.  The $? will be set to false.  You can use the &lt;a href="http://technet.microsoft.com/en-us/library/dd347548.aspx" target="_blank"&gt;trap construct&lt;/a&gt; (or the &lt;a href="http://technet.microsoft.com/en-us/library/dd315350.aspx" target="_blank"&gt;try/catch/finally construct&lt;/a&gt; in V2) to deal with terminating errors and we’ll cover that further in the fourth post in this series.&lt;/p&gt;
&lt;p&gt;If you hit a non-terminating error, the result will depend on the $ErrorActionPreference in the scope or the –ErrorAction parameter.  If the $ErrorActionPreference or –ErrorAction parameter is set to ‘Continue’, the error will be written to the error stream, added to the $error array, and the $? will be set to $false.  ‘SilentlyContinue’ will not write an error to the Error stream, but $error and $? are updated.  Finally, ‘Inquire’ provides you an option at each error as to whether to treat it as terminating or non-terminating.  If treated as a non-terminating error, the error will be treated like the $ErrorActionPreference or –ErrorAction parameter is ‘Continue’.&lt;/p&gt;
&lt;p&gt;Now, I’ve mentioned that some terminating and non-terminating errors both write to the Error stream, so where does that actually get reported back to the user?  If an error has been written to the error stream, it will be written to the output stream (which may surface differently based on the PowerShell host) separately from the pipeline output unless it is redirected.  This means that the exception objects, which are how the errors are represented, are not saved to a variable if you are assigning the pipeline output to a variable.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;p&gt;$results = Get-WMIObject Win32_Bios –ComputerName localhost, ComputerThatDoesNotExist&lt;br /&gt;
Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)&lt;br /&gt;
At line:1 char:22&lt;br /&gt;
+ $results = Get-WmiObject  &amp;lt;&amp;lt;&amp;lt;&amp;lt; Win32_Bios -ComputerName localhost, ComputerThatDoesNotExist&lt;/p&gt;
&lt;p&gt;creates this output to the screen, but $results will only hold the results of the successful WMI query.  This is where the –ErrorVariable comes in.  You can specify a variable to hold the exceptions generated by a particular cmdlet (or in V2 advanced function).  Specifying a variable does not remove an item from being written to the error stream and displayed as output.&lt;/p&gt;
&lt;p&gt;In a console session, you can redirect the error stream with the redirection operators ( 2&amp;gt; or 2&amp;gt;&amp;gt;) or you can merge the error stream with the output stream (2&amp;gt;&amp;amp;1) and write the output to a file, the pipeline, or assign it to a variable.&lt;/p&gt;
&lt;p&gt;Up next:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Error Objects&lt;/li&gt;
&lt;li&gt;Tracing Errors&lt;/li&gt;
&lt;li&gt;Trapping Errors&lt;/li&gt;
&lt;li&gt;Reporting Errors&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Other great &lt;a href="http://support.microsoft.com/kb/968929" target="_blank"&gt;PowerShell&lt;/a&gt; Error Handling posts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://huddledmasses.org/trap-exception-in-powershell/"&gt;http://huddledmasses.org/trap-exception-in-powershell/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blogs.msdn.com/powershell/archive/2006/11/03/erroraction-and-errorvariable.aspx"&gt;http://blogs.msdn.com/powershell/archive/2006/11/03/erroraction-and-errorvariable.aspx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://tfl09.blogspot.com/2009/01/error-handling-with-powershell.html"&gt;http://tfl09.blogspot.com/2009/01/error-handling-with-powershell.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://weblogs.asp.net/adweigert/archive/2007/10/10/powershell-try-catch-finally-comes-to-life.aspx"&gt;http://weblogs.asp.net/adweigert/archive/2007/10/10/powershell-try-catch-finally-comes-to-life.aspx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://powershell.com/cs/blogs/ebook/archive/2009/03/30/chapter-11-finding-and-avoiding-errors.aspx"&gt;http://powershell.com/cs/blogs/ebook/archive/2009/03/30/chapter-11-finding-and-avoiding-errors.aspx&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/75dc0sqQi4Dw6rDO3-rMdjaPQUk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/75dc0sqQi4Dw6rDO3-rMdjaPQUk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/75dc0sqQi4Dw6rDO3-rMdjaPQUk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/75dc0sqQi4Dw6rDO3-rMdjaPQUk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/UsePowershell?a=vtnKbHP2fiI:B1ShSrGycn8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/UsePowershell?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/UsePowershell/~4/vtnKbHP2fiI" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://blog.usepowershell.com/2009/07/deep-dive-error-handling-error-types-part-1/#comments" thr:count="3" />
		<link rel="replies" type="application/atom+xml" href="http://blog.usepowershell.com/2009/07/deep-dive-error-handling-error-types-part-1/feed/atom/" thr:count="3" />
		<thr:total>3</thr:total>
	<feedburner:origLink>http://blog.usepowershell.com/2009/07/deep-dive-error-handling-error-types-part-1/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Steven Murawski</name>
						<uri>http://www.usepowershell.com</uri>
					</author>
		<title type="html"><![CDATA[Exploring the .NET Framework with PowerShell &#8211; Garbage Collection (Part 6)]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UsePowershell/~3/Ux7PCSP1mwo/" />
		<id>http://blog.usepowershell.com/2009/07/exploring-the-net-framework-with-powershell-garbage-collection-part-6/</id>
		<updated>2009-07-07T12:00:00Z</updated>
		<published>2009-07-07T12:00:00Z</published>
		<category scheme="http://blog.usepowershell.com" term=".NET Framework" /><category scheme="http://blog.usepowershell.com" term="PowerShell" />		<summary type="html"><![CDATA[Garbage collection is a process that the .NET Framework (upon which the PowerShell runtime works) uses to manage memory.&#160; The garbage collection (for applications – services are handled a bit differently) process basically covers X steps: Identify objects that won’t be used Delete them from memory Compact the space to make room for new objects [...]]]></summary>
		<content type="html" xml:base="http://blog.usepowershell.com/2009/07/exploring-the-net-framework-with-powershell-garbage-collection-part-6/">&lt;p&gt;Garbage collection is a process that the .NET Framework (upon which the PowerShell runtime works) uses to manage memory.&amp;#160; The garbage collection (for applications – services are handled a bit differently) process basically covers X steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Identify objects that won’t be used &lt;/li&gt;
&lt;li&gt;Delete them from memory &lt;/li&gt;
&lt;li&gt;Compact the space to make room for new objects &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The first step is the critical point for PowerShell users.&amp;#160; You may have noticed how the memory used in a PowerShell session can steadily climb (or suddenly climb if you’re dealing with a large number of objects).&amp;#160; I talked about that in &lt;a href="http://blog.usepowershell.com/2009/03/tip-free-up-some-memory/" target="_blank"&gt;this tip&lt;/a&gt;.&amp;#160; The .NET garbage collector looks for objects that are still in use or could possibly be in use in the near future (this is a gross oversimplification &amp;#8211; if you are really interested in a detailed explanation of how garbage collection works in the .NET Framework, &lt;a href="http://www.simple-talk.com/content/article.aspx?article=737" target="_blank"&gt;check out this article&lt;/a&gt;.) &lt;/p&gt;
&lt;p&gt;What this means to scripters who are running into memory pressure issues is that the garbage collector will not reclaim any objects you have actively referenced (meaning that you’ve assigned them to a variable) in your current or higher scope.&amp;#160; &lt;/p&gt;
&lt;p&gt;Since this can sound a bit convoluted let’s look at an example.&amp;#160; &lt;/p&gt;
&lt;p&gt;I read a large file to parse it and leave the contents of the original stored in a variable&lt;/p&gt;
&lt;p&gt;PS&amp;gt; $MyLargeFile =&amp;#160; &lt;a href="http://go.microsoft.com/fwlink/?LinkID=113310"&gt;Get-Content&lt;/a&gt; MyLargeFile.txt    &lt;br /&gt;PS&amp;gt; Foreach ($line in $MyLargeFile) {    &lt;br /&gt;DoSomething $line | &lt;a href="http://go.microsoft.com/fwlink/?LinkID=113363"&gt;Out-File&lt;/a&gt; NewUpdatedLargeFile.txt    &lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;One of the problems with the above pattern is that the original file remains saved in memory and doesn’t get released unless you explicitly remove the reference, either by using &lt;a href="http://go.microsoft.com/fwlink/?LinkID=113380"&gt;Remove-Variable&lt;/a&gt; or &lt;a href="http://go.microsoft.com/fwlink/?LinkID=113373"&gt;Remove-Item&lt;/a&gt; or by changing what $MyLargeFile points to by assigning another value to it.&amp;#160; &lt;/p&gt;
&lt;p&gt;This isn’t VBScript where you have to set values to “Nothing”, but you should be aware of what larger object sets you are retaining in memory.&amp;#160; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/tBa4LJTl7G-hcCd-eEXvueAgoiI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tBa4LJTl7G-hcCd-eEXvueAgoiI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/tBa4LJTl7G-hcCd-eEXvueAgoiI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tBa4LJTl7G-hcCd-eEXvueAgoiI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/UsePowershell?a=Ux7PCSP1mwo:VAv2_u_88O0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/UsePowershell?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/UsePowershell/~4/Ux7PCSP1mwo" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://blog.usepowershell.com/2009/07/exploring-the-net-framework-with-powershell-garbage-collection-part-6/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://blog.usepowershell.com/2009/07/exploring-the-net-framework-with-powershell-garbage-collection-part-6/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://blog.usepowershell.com/2009/07/exploring-the-net-framework-with-powershell-garbage-collection-part-6/</feedburner:origLink></entry>
	</feed>
