<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://powershell.com/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results for 'app:weblogs' matching tags 'BATCHman' and 'guest blogger'</title><link>http://powershell.com/cs/search/SearchResults.aspx?q=app:weblogs&amp;tag=BATCHman,guest+blogger&amp;orTags=0&amp;o=DateDescending</link><description>Search results for 'app:weblogs' matching tags 'BATCHman' and 'guest blogger'</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 (Build: 30929.2835)</generator><item><title>BATCHman Uses PowerShell to Identify and Unlock User Accounts</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2011/09/11/batchman-uses-powershell-to-identify-and-unlock-user-accounts.aspx</link><pubDate>Sun, 11 Sep 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:12271</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;: BATCHman shows how to use Windows PowerShell to locate and unlock user accounts in Active Directory.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy Ed Wilson here. In the continuing saga of the world&amp;rsquo;s first Windows PowerShell superhero, &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/batchman/"&gt;BATCHman&lt;/a&gt;, and his faithful sidekick, Cmdlet, I once again present Windows PowerShell MVP and &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2011/09/01/honorary-scripting-guy-award-recipients-announced.aspx"&gt;Honorary Scripting Guy&lt;/a&gt; &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/guest+blogger/sean+kearney/"&gt;Sean Kearney&lt;/a&gt;. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.technet.microsoft.com/bb410849.Batchman_Icon_05_bluebatchman_082511(en-us,MSDN.10).png"&gt;&lt;img style="max-width:550px;border:0px;" title="BATCHman and Cmdlet logo" alt="BATCHman and Cmdlet logo" src="http://i.technet.microsoft.com/bb410849.Batchman_Icon_05_bluebatchman_082511(en-us,MSDN.10).png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Whenever trouble happens in systems and people will call,&lt;/p&gt;
&lt;p&gt;And darkness rolls out causing your fall,&lt;/p&gt;
&lt;p&gt;Creatures of bits roam in the night,&lt;/p&gt;
&lt;p&gt;Shine to the sky, the bright bluish Light,&lt;/p&gt;
&lt;p&gt;And call to&amp;hellip;BATCHman !&lt;/p&gt;
&lt;p&gt;&amp;hellip;and, oh yes, his sidekick Boy Blunder Cmdlet, too.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Shock! Terror! The Redmond Police office has been rendered useless! A dark shadow has crossed over the LAN!&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Our accounts! Every account in Active Directory locked out!&amp;rdquo; the police chief stared blankly at the computer screen. He then glared darkly across the hallway at the culprit who is dressed in all black, hissing back at the police chief.&lt;/p&gt;
&lt;p&gt;It was the dreaded Script Kitty, Madame CatFile&amp;rsquo;s only daughter. For years, there was a chance of her not assuming her mother&amp;rsquo;s role of foul villainry, and then the worst happened: she saw the cool clothes evil villains wore, and that was that. She was another victim of fashion.&lt;/p&gt;
&lt;p&gt;Tonight, she had somehow slipped into the office in the guise of one of the cleaning staff and plugged her laptop into an unwatched LAN jack. She ran her &amp;ldquo;AttackCityHall.vbs&amp;rdquo; script in the hopes of unlocking at least one account. Fortunately for the city of Redmond and unfortunately for her, neither time nor password complexity rules was on her side.&lt;/p&gt;
&lt;p&gt;Unfortunately, the city had for security reasons designed its Active Directory to not automatically unlock. Thus, the poor police chief found himself in a predicament.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Hiiiiissssss,&amp;rdquo; Script Kitty hissed again at the chief.&lt;/p&gt;
&lt;p&gt;How dare he walk in on her while she was attempting to hack all of the accounts in the city of Redmond? She would have gotten away, too, if it weren&amp;rsquo;t for that oh-so-cute little mouse. She just &lt;i&gt;had&lt;/i&gt; to pounce on it! After all, it was a pink Arc mouse. &amp;ldquo;So rare! Purrrrr,&amp;rdquo; her mind raced and then she was quickly caught and locked up.&lt;/p&gt;
&lt;p&gt;There was only one account that Script Kitty missed. She, in her haste, somehow overlooked an administrator account.&lt;/p&gt;
&lt;p&gt;The police chief looked over at the blue box on the wall with a small hammer marked, &amp;ldquo;In case of network emergency, break glass and press button.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The glass shattered, the police chief did the one thing he never thought he&amp;rsquo;d need to do: he summoned the BATCHman Klaxons.&lt;/p&gt;
&lt;p&gt;He pressed the &lt;strong&gt;Get-Help&lt;/strong&gt; button, and moments later, 1,000 loudspeakers inside his office began pumping out a 1,000-decibel warning siren along with a blinding light.&lt;/p&gt;
&lt;p&gt;Covering his ears and eyes, he stumbled across the room looking at the deputy. Taking a hammer to the &lt;strong&gt;Get-Help&lt;/strong&gt; button and many sparks later, the sound and light disappeared.&lt;/p&gt;
&lt;p&gt;Staring at his deputy, he cursed, &amp;ldquo;I told you, have them mount the BATCHman warning system &lt;i&gt;outside&lt;/i&gt; the office, not inside!&amp;rdquo; He quickly grabbed his cell phone and dialed BATCHman&amp;rsquo;s private line.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;***Moments later with a THUD and WHUMP***&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Never fear, BATCHman is here!&amp;rdquo; announced BATCHman.&lt;/p&gt;
&lt;p&gt;The police chief looked up still recovering from the massive assault of sound and light. &amp;ldquo;Yes! Thank goodness you&amp;rsquo;re here! We are in dire need of your help!&amp;rdquo; he shouted above the imagined din.&lt;/p&gt;
&lt;p&gt;BATCHman looked. &amp;ldquo;No need to yell, good citizen. We can h&amp;hellip;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The police chief gestured to all the loudspeakers in the office as well as the broken BATCHman blue box.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Ahhhh, not again. Must remember, outside not inside.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Quickly the Police chief guided him to the workstation &amp;ldquo;We&amp;rsquo;re locked out of Active Directory! Only one good account! Need to get in! GUI slow! Ears hurt, too!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman thought for a moment. With Windows PowerShell, they could solve this easily. Nevertheless, they&amp;rsquo;d have to identify the locked-out accounts to make this quick.&lt;/p&gt;
&lt;p&gt;Quickly, he entered the Windows PowerShell console and loaded up the &lt;b&gt;ActiveDirectory&lt;/b&gt; module.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;IMPORT-MODULE ActiveDirectory&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Cmdlet looked over. &amp;ldquo;BATCHman, can we just pull up a user and have it show us whether they are locked out?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Enjoying his sidekick&amp;rsquo;s enthusiasm BATCHman noted, &amp;ldquo;Yes, it is possible using the &lt;b&gt;Properties&lt;/b&gt; parameter, but the &lt;b&gt;ActiveDirectory&lt;/b&gt; module has a far more powerful feature called &lt;b&gt;SEARCH-ADACCOUNT&lt;/b&gt;. To find all users locked out in Active Directory, we type this.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;SEARCH-ADACCOUNT &amp;ndash;lockedout&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;But, Cmdlet, if we need to make this go faster and unlock only the computers in a particular organizational unit or OU, we can specify parameters such as &lt;b&gt;&amp;ndash;searchbase&lt;/b&gt;.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;SEARCH-ADACCOUNT &amp;ndash;searchbase &amp;lsquo;OU=Division31,OU=Locations,DC=Police,DC=Redmond,DC=Local&amp;rsquo; &amp;ndash;lockedout&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Now, we can just quickly &lt;b&gt;UNLOCK&lt;/b&gt; all the accounts by piping the results into &lt;b&gt;UNLOCK-ADACCOUNT&lt;/b&gt;.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;SEARCH-ADACCOUNT &amp;ndash;searchbase &amp;lsquo;OU=Division31,OU=Locations,DC=Police,DC=Redmond,DC=Local&amp;rsquo; &amp;ndash;lockedout | UNLOCK-ADACCOUNT&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Cmdlet blinked. One single line? &amp;ldquo;Holy Simple Simon, BATCHman! Windows PowerShell really &lt;i&gt;is&lt;/i&gt; powerful!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Yes, it is. Now, quickly have the police chief verify that his staff and he can get in.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The police chief logged in and verified all was well. &amp;ldquo;Thank you, BATCHman! You have saved the day! You&amp;rsquo;re our hero!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman covered his ears from the shouting. &amp;ldquo;You&amp;rsquo;re quite welcome good citizen.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Forgotten during all of this, Script Kitty looked up at BATCHman and purred, &amp;ldquo;Your outfit is purrrfectly delightful.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman looked over. &amp;ldquo;Yes, maybe someday you&amp;rsquo;ll learn about the power of good and of Windows PowerShell. Crime not only doesn&amp;rsquo;t pay, it has a far worse budget for cool costumes.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I want to thank Sean for another exciting episode of BATCHman. Join us tomorrow when The Scripting Wife learns about creating a profile for the Windows PowerShell console.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3451689" width="1" height="1" alt="" /&gt;</description></item><item><title>Use PowerShell to Manage Office 365</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2011/09/10/use-powershell-to-manage-office-365.aspx</link><pubDate>Sat, 10 Sep 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:12261</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;b&gt;Summary&lt;/b&gt;: BATCHman battles The Consultant and uses Windows PowerShell to manage Office 365 easily.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy Ed Wilson here. Sean Kearney brings us Episode 8 of the BATCHman series today.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.technet.microsoft.com/bb410849.Batchman_Icon_05_bluebatchman_082511(en-us,MSDN.10).png"&gt;&lt;img style="max-width:550px;" border="0" alt="" src="http://i.technet.microsoft.com/bb410849.Batchman_Icon_05_bluebatchman_082511(en-us,MSDN.10).png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Whenever trouble happens in systems and people will call,&lt;/p&gt;
&lt;p&gt;And darkness rolls out causing your fall,&lt;/p&gt;
&lt;p&gt;Creatures of bits roam in the night,&lt;/p&gt;
&lt;p&gt;Shine to the sky, the bright bluish Light,&lt;/p&gt;
&lt;p&gt;And call to&amp;hellip;BATCHman !&lt;/p&gt;
&lt;p&gt;&amp;hellip;and, oh yes, his sidekick Boy Blunder Cmdlet, too.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;In Today&amp;rsquo;s Episode, BATCHman Encounters the Evil of The Consultant&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Oh, the times are dangerous and frightening. Somewhere in Redmond, a team of IT people is running about madly with their hands in the air.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;AIAHGIHAIGHIH!!! AIHAGHAHGHAGHIHI!!! We can&amp;rsquo;t manage anything! The sky is falling the sky is falling! Aihihighighighhghgi!!!!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Panic (and apparently Henny Penny) has gripped them by the ears. The systems administrator is on the phone madly dialing BATCHman directly.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;BATCHman!!! BATCHman!!! You&amp;rsquo;ve got to help us!!! HURRY!!! AIGHAIHGHAHGHAH!!!!!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Certainly, why we&amp;rsquo;ll be happy to b&amp;hellip;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;He is cut off by more screaming and the sound of breaking glass. &amp;ldquo;HURRY!!! HURRY!!! It&amp;rsquo;s all over!!! AIAGIHGAIH&amp;rdquo; *&lt;b&gt;click&lt;/b&gt;*&lt;/p&gt;
&lt;p&gt;The phone is dead. Cmdlet without blinking yells, &amp;ldquo;To the WinMobile!&amp;rdquo; Cmdlet takes off to the scene in a flash.&lt;/p&gt;
&lt;p&gt;BATCHman is left behind to wonder how he should get there. Our hero, looking about scratching his head, finds the only alternate means of transport.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Well, err,. to the BATCHunicycle!&amp;rdquo; as he deftly hops on and wobbles his way to the crime scene.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;***A good while later***&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;BATCHman arrives. He sees Cmdlet. &amp;ldquo;For future reference, the sidekick does not drive the superhero car,&amp;rdquo; tapping Cmdlet on the nose. &amp;ldquo;You&amp;rsquo;ll take the BATCHunicycle home,&amp;rdquo; he grinned.&lt;/p&gt;
&lt;p&gt;Cmdlet has in the meantime gathers the details. &amp;ldquo;Pretty evil situation. The IT staff came in over the weekend The Consultant migrated them to Office 365.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman is puzzled. That doesn&amp;rsquo;t seem evil. That seems quite nice actually.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;I don&amp;rsquo;t think you&amp;rsquo;re getting it. Not *A* Consultant but *THE* Consultant. He walked in, migrated them, left a bill on the table and didn&amp;rsquo;t tell anybody his plans. They have no instructions or documentation.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman suddenly realizes the issue. One of the nastiest, grungiest creatures on the planet simply called &amp;ldquo;The Consultant&amp;rdquo; had arrived on the scene. His claim to the evil world would be to improve infrastructure, bill clients, and then leave them with no documentation of what happened. Often doing it as a surprise launch on a weekend, his calling card was nasty: a hefty bill and a panicked IT staff on Monday morning.&lt;/p&gt;
&lt;p&gt;However, today The Consultant has met his match. He outdid himself. He used Office 365, and BATCHman and Cmdlet were on the scene.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Never fear, bring the IT staff in here. Let them know BATCHman is on the scene. We can solve all their woes with Windows PowerShell!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Moments later, the mob of IT staff and one very frightened cat gather in the boardroom.&lt;/p&gt;
&lt;p&gt;BATCHman looks at them. &amp;ldquo;Was there anything left behind? Other than the bill?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Senior Systems Administrator Sue walks over. &amp;ldquo;Just this envelope with an ID/password and the words &amp;lsquo;Office 365&amp;rsquo;. Everything is running, but none of our existing systems seems to work for management. We need to create some new users as well as manipulate our existing distribution lists.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman calmly strokes his chin. &amp;ldquo;Office 365, you say? Well, then, as long as you have credentials, we&amp;rsquo;re okay. For basic access, all we need to do is log on to &lt;a href="http://www.office365.com/"&gt;office365.com&lt;/a&gt; with the provided credentials, and we can do everything from there. But never fear. We can use Windows PowerShell as well to manage the email.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman quickly logs on with the provided user ID and password to the Web-based interface for Office365.com, showing them a basic management interface.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Now, normally to create a user in Exchange, we might use the New-Mailbox or Enable-Mailbox cmdlets. But the process for Office 365 isn&amp;rsquo;t too difficult. The workflow is almost identical to Exchange because it&amp;rsquo;s just Exchange in a hosted environment. First, we add the needed modules. The first is the &lt;b&gt;MSONLINE&lt;/b&gt; module, which we download from the Office 365 website.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;IMPORT-MODULE MSONLINE&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Next we provide the credentials to Windows PowerShell using Get-Credential and connect to the Office 365 web services. The &lt;b&gt;UserPrincipalName&lt;/b&gt; or email address and password The Consultant left you are your credentials.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$Cred=GET-CREDENTIAL &lt;br /&gt;CONNECT-MSOLService -credential $Cred&lt;/p&gt;
&lt;p&gt;&amp;ldquo;After this is done, we bring down the Exchange cmdlets using implicit remoting from the Office 365 server.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$s = NEW-PSSESSION -ConfigurationName Microsoft.Exchange -ConnectionUri &lt;a href="https://ps.outlook.com/powershell"&gt;https://ps.outlook.com/powershell&lt;/a&gt; -Credential $Cred -Authentication Basic -AllowRedirection &lt;br /&gt;$importresults=import-pssession $s&lt;/p&gt;
&lt;p&gt;The IT team begins to breathe more clearly. They are not locked out and this is scriptable. Windows PowerShell and BATCHman have once again saved the day.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;After the cmdlets are installed, you&amp;rsquo;ll find that many of the abilities to add and remove distribution groups and memberships are identical to what you&amp;rsquo;re used to because it is just Exchange on the back end. To create a user, however, is slightly different. We must use the following cmdlet.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;NEW-MSOLUSER&lt;/p&gt;
&lt;p&gt;&amp;ldquo;So all you&amp;rsquo;ll need to do to create users is use the previously cached credentials you stored in the &lt;em&gt;$CRED&lt;/em&gt; variable and run the cmdlet like so. This is presuming an email address of &lt;a href="mailto:evilconsultant@contoso.com"&gt;evilconsultant@contoso.com&lt;/a&gt;, the first name of &amp;lsquo;Evil,&amp;rsquo; and the last name of &amp;lsquo;Consultant.&amp;rsquo;&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;NEW-MSOLUSER &amp;ndash;userprincipalname &amp;lsquo;evilconsultant@contoso.com -DisplayName &amp;#39;Evil Consultant&amp;#39; &amp;ndash;Firstname &amp;lsquo;Evil&amp;rsquo; &amp;ndash;Lastname &amp;lsquo;Consultant&amp;rsquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;But BATCHman! Creating users is fine, but what do we do to delete them?! Usually that is coming down the line quicker than creating a user! We need to ensure that when our payroll application disables the staff member, it can still run our existing Windows PowerShell module!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman smiled. &amp;ldquo;I concur that&amp;rsquo;s just as important, but never fear, Windows PowerShell is here!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;They pause as BATCHman quickly types.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;REMOVE-MSOLUSER &amp;ndash;userprincipalname &amp;lsquo;evilconsultant@contoso.com&amp;rsquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;There is also a web-based interface at &lt;a href="http://www.office365.com/"&gt;office365.com&lt;/a&gt; to allow a richer interface to manage the accounts in the system. You&amp;rsquo;ll also find a plethora of online resources to aid in managing the system.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The IT team breathes a sigh of relief. Although The Consultant changed their back end on them, automation is still here to aid them. Being in the cloud did not mean being left alone on the ground, thanks to Windows PowerShell.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;By the way, if you have the card of that particular villain, I&amp;rsquo;d like to pass it along to the Better Business Bureau.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks Sean for this episode of BATCHman. Join us tomorrow for another exciting episode of BATCHman&amp;mdash;Episode 9!&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3450650" width="1" height="1" alt="" /&gt;</description></item><item><title>Convert Hexadecimal to ASCII Using PowerShell</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2011/09/09/convert-hexadecimal-to-ascii-using-powershell.aspx</link><pubDate>Fri, 09 Sep 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:12231</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;: Superhero BATCHman defeats evil Hextor and converts hexadecimal to ASCII to retrieve passwords.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy Ed Wilson here. Sean Kearney is back again, and this time he delivers Episode 7 of the BATCHman series.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.technet.microsoft.com/bb410849.Batchman_Icon_05_bluebatchman_082511(en-us,MSDN.10).png"&gt;&lt;img style="max-width:550px;" border="0" alt="" src="http://i.technet.microsoft.com/bb410849.Batchman_Icon_05_bluebatchman_082511(en-us,MSDN.10).png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Whenever trouble happens in systems and people will call,&lt;/p&gt;
&lt;p&gt;And darkness rolls out causing your fall,&lt;/p&gt;
&lt;p&gt;Creatures of bits roam in the night,&lt;/p&gt;
&lt;p&gt;Shine to the sky, the bright bluish Light,&lt;/p&gt;
&lt;p&gt;And call to&amp;hellip;BATCHman !&lt;/p&gt;
&lt;p&gt;&amp;hellip;and, oh yes, his sidekick Boy Blunder Cmdlet, too.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;In Today&amp;rsquo;s Episode, BATCHman Encounters HEXTOR the Encyptor!&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Panic grips the city! A beacon cuts through the night! It&amp;rsquo;s the BATCHsignal!&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Beep! Beep! beep! Beep!&amp;rdquo; Cmdlet rolls over and executes the &lt;b&gt;Get-Snooze&lt;/b&gt; script. It is naptime in the BATCHcave.&lt;/p&gt;
&lt;p&gt;But not for BATCHman. He deftly grabs Cmdlet&amp;rsquo;s blanket and flips him into the air like a flapjack. &amp;ldquo;No time to waste! Evil is afoot! Quick! To the Winmobile!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Cmdlet looks inside the BATCHbay and sees an empty parking spot.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Uhhhh, BATCHman, where&amp;rsquo;s the Winmobile?&amp;rdquo; gesturing to a large empty rectangle of pavement.&lt;/p&gt;
&lt;p&gt;BATCHman smacks his head . &amp;ldquo;D&amp;rsquo;oh! I forgot I shipped it out for a Mango upgrade! Whatever shall we do?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Holy, Big Ben! What horrible timing! Then to the BATCHsubway! Quick, grab the tokens!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;They disappear into the local mass transit system.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;***Meanwhile in another part of the city***&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;BAA FAA FAA FAA!&amp;rdquo; the evil villain cackles &amp;ldquo;BAA FAA FAA!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Dressed in nothing but dark purple with a large hexagon for a symbol, the evil genius Hextor looks down upon the chaos that has become the local Redmond post office, smiling.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;BAA FAA FAA! All your passwords are belong to me! The systems are locked away. None of you will ever retrieve them! For I have encrypted everything in&amp;hellip;.HEXADECIMAL! BAA FAA FAAAA!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The administrator looks shaken. Decoding hexadecimal! What a foul turn of events! &amp;ldquo;Oh if only BATCHman were here!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;As if by sheer luck, our fearless heroes stumble onto the scene, smelling vaguely of the subway.&lt;/p&gt;
&lt;p&gt;Hextor looks at our heroes with disdain. &amp;ldquo;Nothing can save them. Not you or your silly bad acting sidekick! Everything is written in pure hexadecimal! BAA FAAA FAAA FAAAA!&amp;rdquo; he giggled madly&lt;/p&gt;
&lt;p&gt;Cmdlet stares at Hextor&amp;rsquo;s copy of the user password list. Now written in hexadecimal, it seems impossible to decrypt. &amp;ldquo;Holy magic hexes, BATCHman! He wasn&amp;rsquo;t kidding!&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;50 6f 73 74 61 6c 41 63 63 65 73 73 31 09 55 62 65 72 4c 33 33 74 50 40 73 73 77 30 72 64 0d 0a 53 75 70 65 72 76 69 73 6f 72 09 42 40 74 63 68 4d 40 6e 77 31 6c 6e 76 72 47 33 74 74 68 31 73 21 0d 0a 41 64 6d 69 6e 69 73 74 72 61 74 6f 72 09 21 4b 72 40 35 68 4e 62 75 52 4e 3f 0d 0a 50 6f 73 74 61 6c 41 63 63 65 73 73 32 09 42 75 61 68 21 48 41 3f 68 61 21 48 41 41 41 41 21 3f 21 0d 0a&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Why, foul villian, I believe you&amp;rsquo;re right. Nothing can solve this easily. Nothing that is,&amp;rdquo; BATCHman pauses dramatically with a finger in the air, &amp;ldquo;except Windows PowerShell!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Hextor&amp;rsquo;s eyes open like flying saucers! &amp;ldquo;EEEEEEEEEEEEEEEEEEEEE! AAAAAAAAAA! BAAAAA! &amp;rdquo; is all that escapes his mouth as he runs off hands in the air, immediately sensing defeat.&lt;/p&gt;
&lt;p&gt;BATCHman looks over at Cmdlet. &amp;ldquo;In Windows PowerShell, we can easily convert binary, octal, decimal, and even hexadecimal. It is a native feature. We just need to leverage &lt;b&gt;[CONVERT]&lt;/b&gt;. To quickly convert a number to hexadecimal, I would type this.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;[convert]::tostring(12345,16)&lt;/p&gt;
&lt;p&gt;&amp;ldquo;This will produce the following hexadecimal output.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;3039&lt;/p&gt;
&lt;p&gt;&amp;ldquo;To convert back to decimal, we specify that we&amp;rsquo;re converting to an integer and specify the base we&amp;rsquo;re converting from.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;[convert]::toint16(&amp;ldquo;3039&amp;rdquo;,16)&lt;/p&gt;
&lt;p&gt;Which produces&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;12345&lt;/p&gt;
&lt;p&gt;Cmdlet looked on. &amp;ldquo;Wow, BATCHman! But that doesn&amp;#39;t help us. We need to convert those hexadecimal numbers to decimal and then convert them back to a real ASCII character! I don&amp;rsquo;t think we can convert a number to an ASCII character. That&amp;rsquo;s just lu&amp;hellip;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Hold there, chum. We can do that as well in Windows PowerShell. We just need to type it as a &lt;b&gt;[char]&lt;/b&gt;. When &lt;b&gt;[char]&lt;/b&gt; is followed by any decimal number less than 256, it converts it to an ASCII character. We can even find the ASCII value of characters using the &lt;b&gt;[BYTE]&lt;/b&gt; type like this.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;[BYTE][CHAR]&amp;rsquo;a&amp;rsquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;97&lt;/p&gt;
&lt;p&gt;&amp;ldquo;To convert back, all we do is reverse the process.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;[CHAR][BYTE]97&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;a&lt;/p&gt;
&lt;p&gt;Cmdlet looked at the string of hexadecimal numbers. &amp;ldquo;So if we convert these to decimal, we can just preface the result of each one with &lt;b&gt;[CHAR][BYTE]&lt;/b&gt; and see its ASCII character? That sounds too easy.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;You&amp;rsquo;ve got it on the nose, oh sidekick of mine! Now, the challenge is we need as easy way to split up those hexadecimal pairs to convert them. Any thoughts?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The eager one claps his hands together &amp;ldquo;Split! Holy chopping board, BATCHman! We can take this data, drop it into a string, and run a &lt;b&gt;split&lt;/b&gt; method based upon the spaces separating them!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Cmdlet quickly sets up a simple variable in Windows PowerShell:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$HEXDATA=&amp;rdquo;50 6f 73 74 61 6c 41 63 63 65 73 73 31 09 55 62 65 72 4c 33 33 74 50 40 73 73 77 30 72 64 0d 0a 53 75 70 65 72 76 69 73 6f 72 09 42 40 74 63 68 4d 40 6e 77 31 6c 6e 76 72 47 33 74 74 68 31 73 21 0d 0a 41 64 6d 69 6e 69 73 74 72 61 74 6f 72 09 21 4b 72 40 35 68 4e 62 75 52 4e 3f 0d 0a 50 6f 73 74 61 6c 41 63 63 65 73 73 32 09 42 75 61 68 21 48 41 3f 68 61 21 48 41 41 41 41 21 3f 21 0d 0a&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$HEXDATA.Split(&amp;ldquo; &amp;ldquo;)&lt;/p&gt;
&lt;p&gt;&amp;ldquo;What next? I think you have the idea right!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Well, we could pipe this into &lt;b&gt;ForEach&lt;/b&gt; and apply the &lt;b&gt;[convert]::toint16()&lt;/b&gt; against each like this.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$HEXDATA.Split(&amp;ldquo; &amp;ldquo;) | FOREACH{ [CONVERT]::toint16($_,16)}&lt;/p&gt;
&lt;p&gt;BATCHman rubs his hands together with glee as the decimal numbers pour down the screen. &amp;ldquo;Excellent, Cmdlet! Now with all the decimal numbers, you can just convert them to ASCII, right?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The other half of the terrible twosome added the &lt;b&gt;[CHAR][BYTE]&lt;/b&gt; to the output.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$HEXDATA.Split(&amp;ldquo; &amp;ldquo;) | FOREACH {[BYTE][CHAR]([CONVERT]::toint16($_,16))}&lt;/p&gt;
&lt;p&gt;His jaw dropped. &amp;ldquo;Oh, no, it&amp;rsquo;s just a long unreadable column of letters. I need to write it in a row.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Soooooo, what if we could write to the host with no new line? We can pass your data to the &lt;b&gt;Write-Host&lt;/b&gt; cmdlet without dumping a line feed between each out like so.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$HEXDATA.Split(&amp;ldquo; &amp;ldquo;) | FOREACH {WRITE-HOST &amp;ndash;object ( [BYTE][CHAR]([CONVERT]::toint16($_,16))) &amp;ndash;nonewline }&lt;/p&gt;
&lt;p&gt;Cmdlet stared in awe as the message on the screen converted back to ASCII.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;PostalAccess1 UberL33tP@ssw0rd &lt;br /&gt;Supervisor B@tchM@nw1lnvrG3tth1s! &lt;br /&gt;Administrator !Kr@5hNbuRN? &lt;br /&gt;PostalAccess2 Buah!HA?ha!HAAAA!?!&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Now, quickly get the credentials reset before Hextor strikes again!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Quickly the credentials were reset and the Redmond post office was back online. The postmaster stepped out to shake their hands.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Oh, BATCHman, thank you! How can we ever repay you now that you&amp;rsquo;ve returned our passwords to us?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;No thanks necessary, but any chance you have a stamp? I have to mail this to my mother for her birthday.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks, Sean, for another awesome episode of BATCHman. Everyone, join us tomorrow for Episode 8.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3450653" width="1" height="1" alt="" /&gt;</description></item><item><title>BATCHman Uses PowerShell to Import a CSV File into His SQL Server</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2011/09/04/batchman-uses-powershell-to-import-a-csv-file-into-his-sql-server.aspx</link><pubDate>Sun, 04 Sep 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:12116</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;: Windows PowerShell superhero BATCHman quickly imports CSV data into his SQL Server.&lt;/p&gt;
&lt;p class="CodeBlock"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy Ed Wilson here. Sean Kearney is back today with Episode 6 of the BATCHman series.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;b&gt;Note&amp;nbsp; &lt;/b&gt;&amp;nbsp;You can read all gripping, engaging, informative, and downright funny &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/windows+powershell/guest+blogger/batchman/"&gt;BATCHman episodes&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-width:550px;border:0px;" title="BATCHman and Cmdlet logo" alt="BATCHman and Cmdlet logo" src="http://i.technet.microsoft.com/bb410849.Batchman_Icon_05_bluebatchman_082511(en-us,MSDN.10).png" /&gt;&lt;/p&gt;
&lt;p&gt;Whenever trouble happens in systems and people will call, &lt;br /&gt;and darkness rolls out causing your fall, &lt;br /&gt;Creatures of bits roam in the night, &lt;br /&gt;Shine to the sky, the bright bluish light,&lt;/p&gt;
&lt;p&gt;and call to&amp;hellip;BATCHman !&lt;/p&gt;
&lt;p&gt;&amp;hellip;and, oh yes, his sidekick Boy Blunder Cmdlet, too.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;In Today&amp;rsquo;s Episode, BATCHman Encounters Cmdlet&amp;rsquo;s Bad Field Notes!&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;So after a long week of crusading, standing on Telephones, being blinded by overcharged BATCHsignals, and generally keeping those ne&amp;rsquo;er-do-well evildoers at bay, BATCHman and Cmdlet are now about to upload all of Cmdlet&amp;rsquo;s notes to the BATCHcomputer. (No, forget that thought. It does not BATCH process with COBOL!)&lt;/p&gt;
&lt;p&gt;&amp;ldquo;So, Cmdlet, let&amp;rsquo;s get those notes off your local SQL Express database and merge them from the Batch applet I created for taking field notes. Time to compile some data!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Uhhhh,&amp;rdquo; is Cmdlet&amp;rsquo;s only response. &amp;ldquo;What&amp;rsquo;s a Batch applet?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman stands there scratching thoughtfully on his chin. &amp;ldquo;Why that would be the application I provided to you to keep field notes about all those evil villains we planned to encounter. I wrote it specifically to just simply sync up with the SQL 2008 R2 batch database on the batch computer.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Cmdlet shuffled his feet. &amp;ldquo;Sooooo, not the batch Excel sheet?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;A pause of realization. &amp;ldquo;No.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;More shuffling by our Boy Blunder. &amp;ldquo;So, not Notepad? Not the XML editor?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman just stood there. His beautiful applet, enabled with Windows PowerShell cmdlets, the GUI written with PrimalScript with some tweaking from PowerBoots. And it has gone unused.&lt;/p&gt;
&lt;p&gt;&amp;quot;Cmdlet, can I see your notes?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Boy Blunder hands over his Slate PC to BATCHman. Quickly, BATCHman keys into Windows PowerShell.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-CHILDITEM $HOME\Documents\CmdletNotes&lt;/p&gt;
&lt;p&gt;The output produces some dismay to the BATCHman.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;BADGUYS.CSV&lt;/p&gt;
&lt;p&gt;&amp;ldquo;A CSV file?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Well, we were in the heat of battle, and I just quickly grabbed what was available to me. I thought it would be easy to search and sort and I&amp;hellip;I&amp;hellip;OH PLEASE! PLEASE BE MERCIFUL! PLEASE DON&amp;rsquo;T DECOMPILE ME!!!&amp;rdquo; Cmdlet wailed&lt;/p&gt;
&lt;p&gt;BATCHman shook his head with a smile and tapped his young friend gently on the shoulder. &amp;ldquo;It was a mistake and an honest one. But remember, we have Windows PowerShell. We just need to convert this data into something the batch database will recognize. So let&amp;rsquo;s take a quick look at your CSV file.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;IMPORT-CSV BADGUYS.CSV&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/0246.HSG_2D00_9_2D00_4_2D00_11_2D00_2.jpg"&gt;&lt;img style="border:0px;" title="Image of CSV file contents" alt="Image of CSV file contents" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/0246.HSG_2D00_9_2D00_4_2D00_11_2D00_2.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Well this isn&amp;rsquo;t so bad. All we need to do is match these fields with ones from the BATCHman database. Because Windows PowerShell will work with SQL, we could literally import your CSV file into the database. First, we&amp;rsquo;ll add the SQL snap-ins to allow us to work with SQL Server from Windows PowerShell.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;ADD-PSSNAPIN SqlServerProviderSnapin100 &lt;br /&gt;ADD-PSSNAPIN SqlServerCmdletSnapin100&lt;/p&gt;
&lt;p&gt;&amp;ldquo;With these added we can use &lt;b&gt;Invoke-SQLCmd&lt;/b&gt;, which will allow us to pass SQL queries directly from Windows PowerShell, returning the results as an object. As an example, here is our current query. Because this is a small database, we&amp;rsquo;ll just use this. This presumes that the user, me in this case, has access.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Invoke-Sqlcmd -Query &amp;#39;SELECT * FROM BATCHmanDB.dbo.BATCHmanCrimeTable&amp;#39; -ServerInstance localhost&lt;/p&gt;
&lt;p&gt;Cmdlet looked as the output appeared on the screen. You could tell by the single row of data they were very early into the crime fighting game, and BATCHman started at an early age.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5811.HSG_2D00_9_2D00_4_2D00_11_2D00_3.jpg"&gt;&lt;img style="border:0px;" title="Image of query output" alt="Image of query output" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5811.HSG_2D00_9_2D00_4_2D00_11_2D00_3.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;But BATCHman? How does this help us? All this did was show us information in a SQL database! We need to take my data and place that in SQL! Oh please! Just let me retype it!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman smiled. &amp;ldquo;Because little buddy, this is a Windows PowerShell object. I can do this, too.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$DATA=(Invoke-Sqlcmd -Query &amp;#39;SELECT * FROM BATCHman.dbo.BATCHmanCrimeTable&amp;#39; -ServerInstance localhost)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$DATA.CriminalName&lt;/p&gt;
&lt;p&gt;Cmdlet looked and realized he was now looking at an object in Windows PowerShell as normal. A light lit in his eyes.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Wait! Do you mean I could put Windows PowerShell objects in an SQL query and populate the BATCHman database?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Exactly!&amp;rdquo; decried BATCHman, nearly poking Cmdlet in the eye. So first, let&amp;rsquo;s look at your file. It appears &lt;b&gt;Villain&lt;/b&gt; will be the same as &lt;b&gt;Criminal Name&lt;/b&gt;, &lt;b&gt;Appearance&lt;/b&gt; matches &lt;b&gt;Description&lt;/b&gt;, but the other two are dead on the nose. There are some fields you don&amp;rsquo;t have, such as &lt;b&gt;Solved&lt;/b&gt;, but these are not required in the database. We can edit these later if we choose. Our only challenge now is to build the query.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman pulled open his slate and launched SQL Server Management Studio.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;A very simple SQL &lt;b&gt;INSERT&lt;/b&gt; query to add a row to the BATCHman database would look like this.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;INSERT INTO [BATCHmanDB].[dbo].[BATCHmanCrimeTable] &lt;br /&gt;([CriminalName],[Description],[Problem],[Solution]) &lt;br /&gt;VALUES &lt;br /&gt;(&amp;lsquo;SomeEvilGuy&amp;rsquo;,&amp;rsquo;Looks Awful Funny&amp;rsquo;,&amp;rsquo;Something bad&amp;rsquo;,&amp;rsquo;Something Good&amp;rsquo;) &lt;br /&gt;GO&lt;/p&gt;
&lt;p&gt;&amp;ldquo;We can easily make this a value in Windows PowerShell like this,&amp;rdquo; BATCHman noted.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$SQLQUERY=&amp;rdquo;INSERT INTO [BATCHmanDB].[dbo].[BATCHmanCrimeTable] ([CriminalName],[Description],[Problem],[Solution]) VALUES (&amp;lsquo;SomeEvilGuy&amp;rsquo;,&amp;rsquo;Looks Awful Funny&amp;rsquo;,&amp;rsquo;Something bad&amp;rsquo;,&amp;rsquo;Something Good&amp;rsquo;)&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The eyes of Cmdlet opened wide. &amp;ldquo;BATCHman! That&amp;rsquo;s almost unreadable! Couldn&amp;rsquo;t I just do this?&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$SQLHEADER=&amp;rdquo;INSERT INTO [BATCHmanDB].[dbo].[BATCHmanCrimeTable] ([CriminalName],[Description],[Problem],[Solution])&amp;ldquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$SQLVALUES=&amp;rdquo;VALUES (&amp;lsquo;SomeEvilGuy&amp;rsquo;,&amp;rsquo;Looks Awful Funny&amp;rsquo;,&amp;rsquo;Something bad&amp;rsquo;,&amp;rsquo;Something Good&amp;rsquo;)&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$SQLQUERY=$SQLHEADER+$SQLVALUES&lt;/p&gt;
&lt;p&gt;BATCHman beamed. &amp;ldquo;Excellent! You&amp;rsquo;ve been learning well. Now let&amp;rsquo;s take your notes and begin importing them into the database. We could just write it in a single line, but let&amp;rsquo;s take it one piece at a time. Let&amp;rsquo;s store your CSV file in a variable.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$DATA=IMPORT-CSV BADGUYS.CSV&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Now we&amp;rsquo;ll step through each line with a &lt;b&gt;Foreach-Object&lt;/b&gt;.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;FOREACH ($LINE in $DATA)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;{&lt;br /&gt;$Criminal=$Line.Villain&lt;br /&gt;$Description=$Line.Appearance&lt;br /&gt;$Problem=$Line.Problem&lt;br /&gt;$Solution=$Line.Solution&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;}&lt;/p&gt;
&lt;p&gt;Cmdlet watched the CSV flow on the screen. &amp;ldquo;So, BATCHman, can we just substitute the Windows Powershell variables for the same samples in the query?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman nodded. &amp;ldquo;With one exception: we need to make sure the single quotes are still surrounding the data because the SQL query is expecting them. So we will populate the values like this, remembering the quotation mark is a special character and will need an escape before each reference.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$Criminal=&amp;quot;`&amp;#39;&amp;quot;+$Line.Villain+&amp;quot;`&amp;#39;&amp;quot;&lt;br /&gt;$Description=&amp;quot;`&amp;#39;&amp;quot;+$Line.Appearance&amp;quot;`&amp;#39;&amp;quot;&lt;br /&gt;$Problem=&amp;quot;`&amp;#39;&amp;quot;+$Line.Problem&amp;quot;`&amp;#39;&amp;quot;&lt;br /&gt;$Solution=&amp;quot;`&amp;#39;&amp;quot;+$Line.Solution&amp;quot;`&amp;#39;&amp;quot;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;So we can now just replace them in the query? Do you mean like this?&amp;rdquo; Cmdlet quickly edits the query lines.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$SQLHEADER=&amp;rdquo;INSERT INTO [BATCHmanDB].[dbo].[BATCHmanCrimeTable] ([CriminalName],[Description],[Problem],[Solution])&amp;ldquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$SQLVALUES=&amp;rdquo;VALUES ($Criminal,$Description,$Problem,$Solution)&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$SQLQUERY=$SQLHEADER+$SQLVALUES&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Correct, now we drop that into our script so that we end up with this.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$DATA=IMPORT-CSV BADGUYS.CSV&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;FOREACH ($LINE in $DATA)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;{&lt;br /&gt;$Criminal=&amp;quot;`&amp;#39;&amp;quot;+$Line.Villain+&amp;quot;`&amp;#39;&amp;quot;&lt;br /&gt;$Description=&amp;quot;`&amp;#39;&amp;quot;+$Line.Appearance+&amp;quot;`&amp;#39;&amp;quot;&lt;br /&gt;$Problem=&amp;quot;`&amp;#39;&amp;quot;+$Line.Problem+&amp;quot;`&amp;#39;&amp;quot;&lt;br /&gt;$Solution=&amp;quot;`&amp;#39;&amp;quot;+$Line.Solution+&amp;quot;`&amp;#39;&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$SQLHEADER=&amp;rdquo;INSERT INTO [BATCHmanDB].[dbo].[BATCHmanCrimeTable] ([CriminalName],[Description],[Problem],[Solution])&amp;ldquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$SQLVALUES=&amp;rdquo;VALUES ($Criminal,$Description,$Problem,$Solution)&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$SQLQUERY=$SQLHEADER+$SQLVALUES&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Invoke-Sqlcmd &amp;ndash;Query $SQLQuery -ServerInstance localhost&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;}&lt;/p&gt;
&lt;p&gt;They executed the script, quickly populating the BATCHman database with the needed data. Cmdlet wiped the sweat off his face with a pair of Vibram shoes he found by the door.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;No sweat, little buddy. With Windows PowerShell, almost any problem can be eliminated. Now, let me show you the cool features for taking your notes.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Sean, many thanks for sharing these episodes of BATCHman. Everyone, join us tomorrow as guest blogger Thiyagu talks about Exchange Best Practice Analyzer XML Parser&lt;b&gt;. &lt;/b&gt;&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3449496" width="1" height="1" alt="" /&gt;</description></item><item><title>BATCHman Foils the Fowl Ping Win and Repairs the Registry</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2011/09/03/batchman-foils-the-fowl-ping-win-and-repairs-the-registry.aspx</link><pubDate>Sat, 03 Sep 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:12111</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;: In this episode, superhero BATCHman foils the fowl villain Ping Win and repairs the registry.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy Ed Wilson here. Today is Episode 5 of the BATCHman series by Sean Kearney.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;b&gt;Note&amp;nbsp; &lt;/b&gt;&amp;nbsp;You can read all gripping, engaging, informative, and downright funny &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/windows+powershell/guest+blogger/batchman/"&gt;BATCHman episodes&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.technet.microsoft.com/bb410849.Batchman_Icon_05_bluebatchman_082511(en-us,MSDN.10).png"&gt;&lt;img style="max-width:550px;border:0px;" title="BATCHman and Cmdlet logo" alt="BATCHman and Cmdlet logo" src="http://i.technet.microsoft.com/bb410849.Batchman_Icon_05_bluebatchman_082511(en-us,MSDN.10).png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Whenever trouble happens in systems and people will call, &lt;br /&gt;and darkness rolls out causing your fall, &lt;br /&gt;Creatures of bits roam in the night, &lt;br /&gt;Shine to the sky, the bright bluish light,&lt;/p&gt;
&lt;p&gt;and call to&amp;hellip;BATCHman !&lt;/p&gt;
&lt;p&gt;&amp;hellip;and, oh yes, his sidekick Boy Blunder Cmdlet, too.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In Today&amp;rsquo;s Episode, BATCHman Encounters Ping Win&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Flying through the night in the new BATCHcopter, BATCHman begins veering off course dramatically.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Aiaighahighiahgihi!!! My eyes! Such BRIGHT BLUE LIGHT!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Holy bluebird of sharpness!&amp;rdquo; screams Cmdlet. &amp;ldquo;It&amp;rsquo;s the BATCHsignal!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Yes, Boy Blunder, trouble calls us.&amp;rdquo; BATCHman calls up the new crime fighting one-liner:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-TROUBLE | INVOKE-LAND &amp;ndash;location $_.Source&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;In moments, they are at the scene, the trouble, the issue at hand. It appears that all the firewalls at the Redmond Community Center have been shut down somehow! Home pages have been set to &amp;ldquo;pingwinrulez.com&amp;rdquo;! All search queries have been routed to pingwinrulez.com. What dastardly villain would do such a thing?&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Holy earthworm, BATCHman! All of these computers accessed by kids! Surfing whatever they want unprotected! What villain, what creature of the night, who would do.&amp;hellip;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman taps Cmdlet on the shoulder and points to a rather obvious character off to his left.&lt;/p&gt;
&lt;p&gt;Cmdlet looks. &amp;ldquo;Holy mackerel, BATCHman! It&amp;rsquo;s the Pin&amp;hellip;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Ahh, Boy Blunder.&amp;rdquo; BATCHman taps the side of his nose shaking his head.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Oh&amp;hellip;er&amp;hellip;uh&amp;hellip;right&amp;hellip;it&amp;rsquo;s&amp;hellip;it&amp;rsquo;s&amp;hellip;&amp;rdquo; Cmdlet stammers staring at the oddly dressed black-and-white flightless fowl-looking person.&lt;/p&gt;
&lt;p&gt;The strange character sees the Static Duo. &amp;ldquo;Meh. Allow me to introduce myself. I am&amp;hellip;,&amp;rdquo; he pauses dramatically before he rips open his jacket, &amp;ldquo;&amp;hellip;PING WIN! Meh heh hehe!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The words &amp;ldquo;PING WIN&amp;rdquo; flash in a mad pulsing fashion, surrounded in blinking lights from a large, very expensive-looking neon sign hanging over his shirt.&lt;/p&gt;
&lt;p&gt;BATCHman pauses for a moment, looking. &amp;ldquo;Ah&amp;rdquo; is all he can say. He looks at Cmdlet. &amp;ldquo;Was this really necessary?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Cmdlet nods. &amp;ldquo;The blog post went way under budget. We had to burn up some funds. Cool shirt, eh?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Getting a hold of himself, BATCHman gets back into character. &amp;ldquo;So Ping Win, you&amp;rsquo;ve downed all the firewalls, eh? To what end? Why?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Antivirus Software! To rid themselves of this problem and all the annoying popups, it will advertise nothing but PingWin-Nev-R-Fayl Antivirus! I will become a trillionaire! Muah har herh hah!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;As Ping Win dances his previctory dance, he trips over one of fifty wires running the neon lights on his shirt and collapses, knocked senseless by his own silliness.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;I thought he&amp;rsquo;d never shut up!&amp;rdquo; muttered Cmdlet. &amp;ldquo;So BATCHman, how do we solve this?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;How else? With a BATCH file and some Windows PowerShell!&amp;rdquo; he proudly declares with his hands on the BATCH module belt, standing heroically. First, we must ensure the firewall service is started on all of these systems. We will get the status of it using the &lt;b&gt;Get-Service&lt;/b&gt; cmdlet.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-SERVICE &amp;ldquo;Windows Firewall&amp;rdquo;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;We can see on this machine that it&amp;rsquo;s stopped.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5381.HSG_2D00_9_2D00_3_2D00_11_2D00_2.jpg"&gt;&lt;img style="border:0px;" title="Image showing Windows Firewall has stopped" alt="Image showing Windows Firewall has stopped" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5381.HSG_2D00_9_2D00_3_2D00_11_2D00_2.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;To restart it, we can pipe it into the Start-Service cmdlet.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-SERVICE &amp;ldquo;Windows Firewall&amp;rdquo; | START-SERVICE&lt;/p&gt;
&lt;p&gt;Cmdlet is rapidly opening up his copy of PowerGUI to begin building the script for rapid deployment.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Now,&amp;rdquo; he mumbled as he gnawed on his cape, &amp;ldquo;to reset those home pages. Need to get this done fast.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;For a moment, he eyed a large cache of energy drinks and pictured Cmdlet running about like a gerbil clicking away on GUI options. He smiled.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Nah! Let&amp;rsquo;s use the registry!&amp;rdquo; he thought aloud. &amp;ldquo;So to change these home pages and how he&amp;rsquo;s redirected the search, we&amp;rsquo;ll need to directly access the registry for each user. The settings we need are all under this key.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;ldquo;HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\&amp;rdquo;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Using Regedit, BATCHman shows Cmdlet an example of what Ping Win had done.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5444.HSG_2D00_9_2D00_3_2D00_11_2D00_3.jpg"&gt;&lt;img style="border:0px;" title="Image of editing string with Regedit" alt="Image of editing string with Regedit" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5444.HSG_2D00_9_2D00_3_2D00_11_2D00_3.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;And there are three values we need to fix: &lt;b&gt;Start Page&lt;/b&gt;, &lt;b&gt;Search Page&lt;/b&gt;, and possibly even &lt;b&gt;Default_Page_Url&lt;/b&gt;. As you can see, Cmdlet, he&amp;rsquo;s modified &lt;b&gt;Default_Page_Url&lt;/b&gt; to point to his own private dastardly site. But we can easily access the registry using Windows PowerShell. We can access the registry using a built-in provider. To get the list of available providers, we simply type this.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-PSPROVIDER&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/0488.HSG_2D00_9_2D00_3_2D00_11_2D00_4.jpg"&gt;&lt;img border="0" alt="" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/0488.HSG_2D00_9_2D00_3_2D00_11_2D00_4.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Holy convenience store, BATCHman! HKCU is marked as a drive! Do you mean if I were to type &lt;em&gt;&lt;b&gt;SET-LOCATION HKCU:&lt;/b&gt;&lt;/em&gt;&lt;em&gt;, I&lt;/em&gt; would be navigating the registry?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Not only that but if you ran a &lt;b&gt;GET-CHILDITEM&lt;/b&gt; against it, you would see that part of the registry: &lt;em&gt;&lt;b&gt;GET-CHILDITEM HKCU:&lt;/b&gt;&lt;/em&gt;&lt;em&gt; Or we can&lt;/em&gt; even recurse: &lt;em&gt;&lt;b&gt;GET-CHILDITEM HKCU: &amp;ndash;recurse&lt;/b&gt;&lt;/em&gt;&lt;em&gt;.&amp;rdquo;&lt;/em&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Cmdlet pauses in thought. &amp;ldquo;So to access the available registry keys for &lt;em&gt;&lt;b&gt;HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\&lt;/b&gt;&lt;/em&gt;&lt;em&gt; &lt;/em&gt;all I have to do is enter:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-CHILDITEM HKCU:\Software\Microsoft\Internet Explorer\Main\&lt;/p&gt;
&lt;p&gt;BATCHman smiled. &amp;ldquo;Close, my little digital partner, but not quite. You would need to execute a &lt;b&gt;GET-ITEM&lt;/b&gt; because that is how the registry tree branches are recognized by Windows PowerShell. The CHILDITEMs in this case are actually just other available branches under &lt;em&gt;&lt;b&gt;HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\&lt;/b&gt;&lt;/em&gt;. To see what is attached to the main branch, we type this.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-ITEM HKCU:\Software\Microsoft\Internet Explorer\Main\&lt;/p&gt;
&lt;p&gt;&amp;ldquo;And that shows us it has &lt;b&gt;Properties&lt;/b&gt; attached to it.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/2538.HSG_2D00_9_2D00_3_2D00_11_2D00_05.jpg"&gt;&lt;img style="border:0px;" title="Image showing what is attached to branch" alt="Image showing what is attached to branch" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/2538.HSG_2D00_9_2D00_3_2D00_11_2D00_05.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;To access and see what values are available under the main branch, we need only attach the property name, which oddly in this case is called &lt;b&gt;Property,&lt;/b&gt; to the original line in Windows PowerShell.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;(GET-ITEM HKCU:\Software\Microsoft\Internet Explorer\Main\).Property&lt;b&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Now if we need to pull down the values of a PROPERTY from an ITEM in the registry, we do this.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-ITEMPROPERTY &amp;ndash;path &amp;ldquo;Registry::HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main&amp;ldquo;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Cmdlet blinked as he saw all the registry values from the &lt;b&gt;Main&lt;/b&gt; key appear on the screen. &amp;ldquo;Holy Bee Hive!&amp;rdquo; he muttered.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Now of course if we need to see a particular value, such as say &lt;b&gt;Default_Page_Url&lt;/b&gt;, we type this.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-ITEMPROPERTY &amp;ndash;path &amp;ldquo;Registry::HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main&amp;ldquo; &amp;ndash;name &amp;ldquo;Default_Page_Url&amp;rdquo;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;But BATCHman, you&amp;rsquo;ve forgotten the most important part! We need to fix them and fix them &lt;i&gt;now&lt;/i&gt;! Kids are due to arrive in minutes!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman realized he got a little too carried away in chatting about Windows PowerShell and had almost forgotten the task at hand. &amp;ldquo;Yes! Of course! So all we need to do to set the value in a key.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;SET-ITEMPROPERTY &amp;ndash;path &amp;ldquo;Registry::HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main&amp;ldquo; &amp;ndash;name &amp;ldquo;Default_Page_Url&amp;rdquo; &amp;ndash;Value &amp;ldquo;http://www.msn.com&amp;rdquo;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Cmdlet looked and took the initiative. &amp;ldquo;So for the remaining keys to put in some proper values, I need only do this?&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;SET-ITEMPROPERTY &amp;ndash;path &amp;ldquo;Registry::HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main&amp;ldquo; &amp;ndash;name &amp;ldquo;Start Page&amp;rdquo; &amp;ndash;Value &amp;ldquo;http://www.msn.com&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;SET-ITEMPROPERTY &amp;ndash;path &amp;ldquo;Registry::HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main&amp;ldquo; &amp;ndash;name &amp;ldquo;Search Page&amp;rdquo; &amp;ndash;Value &amp;ldquo;http://www.bing.com&amp;rdquo;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Exactly! Now let&amp;rsquo;s save this script and try it on a machine!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;But BATCHman! We need to alter their personal settings as well! How will we do that easily? And quickly?! We only have moments before the center opens!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman thought about it. How to alter those settings automatically with this script? &amp;ldquo;Of course!&amp;rdquo; his fingers snapped, sending shockwaves. &amp;ldquo;We&amp;rsquo;ll use Group Policy and set it as a startup script! As they log in, it will overwrite all the mess Ping Win turned loose!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman quickly navigated to the computer configuration and dropped in a reference to his script in the SYSVOL share. Soon, people began to arrive. They logged in. Nobody noticed anything odd.&lt;/p&gt;
&lt;p&gt;Ping Win began to recover from his trip over the chords. He looked. No disgusted reactions. Happy people. &amp;ldquo;Meeeeeea! FOILED!&amp;rdquo; he screamed and fell over another power cord.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Cmdlet,&amp;rdquo; the BATCHman said watching Ping Win &amp;ldquo;Next time, let&amp;rsquo;s avoid buying the arch villain a big neon sign he can trip over. We could have spent that money on tires for the WinMobile&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Sean, thanks for another awesome episode of &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/windows+powershell/guest+blogger/batchman/"&gt;BATCHman&lt;/a&gt;. Everyone, join us tomorrow for Episode 6.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3449493" width="1" height="1" alt="" /&gt;</description></item><item><title>BATCHman Uses PowerShell to Thwart Dr. Regex and Save the Zoo</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2011/09/02/batchman-uses-powershell-to-thwart-dr-regex-and-save-the-zoo.aspx</link><pubDate>Fri, 02 Sep 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:12103</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;: In this exciting episode, BATCHman uses Windows PowerShell and regular expressions to thwart the evil Dr. Regex and save the monkeys.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy, Ed Wilson, is here. Sean Kearney is back with us for three more episodes of the thrilling BATCHman series. Today is Episode 4.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-width:550px;" border="0" alt="BATCHman and Cmdlet logo" src="http://i.technet.microsoft.com/bb410849.Batchman_Icon_05_bluebatchman_082511(en-us,MSDN.10).png" /&gt;&lt;/p&gt;
&lt;p&gt;Whenever trouble happens in systems and people will call, &lt;br /&gt;and darkness rolls out causing your fall, &lt;br /&gt;Creatures of bits roam in the night, &lt;br /&gt;Shine to the sky, the bright bluish Light,&lt;/p&gt;
&lt;p&gt;and call to&amp;hellip;BATCHman !&lt;/p&gt;
&lt;p&gt;&amp;hellip;and, oh yes, his sidekick Boy Blunder Cmdlet, too.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;In Today&amp;rsquo;s Episode, BATCHman Encounters Doctor Regex!&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Cutting through the midnight blue sky, a beacon for justice, a light for freedom calls out!&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Holy shell, BATCHman! It&amp;rsquo;s the BATCHsignal! We have&amp;hellip;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Ahem, Cmdlet, I would suggest you watch your language there. This is after all a &amp;lsquo;G&amp;rsquo; rated blog post.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;But but, I&amp;hellip;I&amp;hellip;ugh&amp;hellip;yes, BATCHman,&amp;rdquo; he sullenly bowed in defeat. &amp;ldquo;Shall I fire up the WinMobile?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;No, but you can start it,&amp;rdquo; snickered our hero. &amp;ldquo;To the WinMobile!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Buckling under the weight of our heroes, the WinMobile moved off. &amp;ldquo;Thank goodness it&amp;rsquo;s made of Gorilla Glass,&amp;rdquo; muttered Cmdlet.&lt;/p&gt;
&lt;p&gt;Meanwhile, somewhere else in the city of Redmond, evil has placed a call. The arch criminal simply known as the dreaded Dr. Regex has visited. Cursed after too many nights of writing parse queries, our arch villain only speaks in riddles of Regex. He has taken the team at the local Redmond Zoo by surprise. All the cages are being unlocked, potentially unleashing the vicious GUI eating SAPIEN monkeys! Our arch villain dances off on top of the cages laughing maniacally in an oddly cheeseburger colored jumpsuit with his big &amp;ldquo;!&amp;rdquo; symbol. &amp;ldquo;Muah ha haaaaa!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The only passcode to the electronic Chubb lock system has been left somewhere in this cryptic riddle left on Notepad on the desktop of the main server:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Evil may Come And Evil May Go &lt;br /&gt;The BATCHman Will Seek, be Fast Or Be Slow &lt;br /&gt;But Soon On the Day The pass It Must Be &lt;br /&gt;The word Should He Say, To Not Set Them Free &lt;br /&gt;is The BATCHman Too Smart, Or Is He Not Bright? &lt;br /&gt;under The Stars And Under the Light! &lt;br /&gt;The key We Shall See, Unlocking This Clue &lt;br /&gt;Will chain Them All Down, Or Let Them Run Through&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Signed ^[Dr!Regex]^&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/1033.HSG_2D00_9_2D00_2_2D00_11_2D00_2.jpg"&gt;&lt;img style="border:0px;" title="Photo of the evil Dr. Regex" alt="Photo of the evil Dr. Regex" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/1033.HSG_2D00_9_2D00_2_2D00_11_2D00_2.jpg" width="200" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BATCHman and Cmdlet arrive on the scene, the sound of Monkeys about to tear scripts apart. Cmdlet stared at the riddle. &amp;ldquo;Holy twisted blisters, BATCHman! That must have worn out somebody&amp;rsquo;s fingers typing! What a bizarre rid&amp;hellip;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;&amp;hellip;.bizarre clue!&amp;rdquo; corrected BATCHman &amp;ldquo;Yes. Yes, indeed. What a strange person. There must be some type of pattern in this clue. Something usual to the naked human eye, something I can&amp;rsquo;t quite see, some&amp;hellip;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;BATCHman! It appears only certain words start with a lowercase letter!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Cmdlet! Excellent ! How did you spot it so quickly?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;It&amp;rsquo;s written here in the plot, page 5, line 7&amp;hellip;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman looks down scratching his cowl. &amp;ldquo;Ah, so it is.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;So we could just write down every word,&amp;rdquo; suggested Cmdlet.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Pah! And waste a good chance to use Windows PowerShell? Never! This is a perfect opportunity to use regular expressions to find those matches! First, we need to identify the pattern. We need all words starting with a lowercase letter only. Within regular expressions, that would be a matter of specifying that the first letter is from &lt;i&gt;a&lt;/i&gt; to &lt;i&gt;z&lt;/i&gt; only like this.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;[a-z]&lt;/p&gt;
&lt;p&gt;&amp;ldquo;And then we&amp;rsquo;ll need to specify it&amp;rsquo;s at the beginning of the word.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;\b[a-z]&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Then we&amp;rsquo;ll specify that the word must be at least two letters long if we find it, but can be as long as we want. This should trap our series of words.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;\b[a-z]{2,}&lt;/p&gt;
&lt;p&gt;&amp;ldquo;With this in place, Cmdlet, we need to pipe the information from the text file into a &lt;b&gt;Select-String&lt;/b&gt; statement like this.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-CONTENT C:\EVILCLUE.TXT | SELECT-STRING &amp;lsquo;\b[a-z]{2,}&amp;rsquo;&lt;/p&gt;
&lt;p&gt;Cmdlet sat there cross-legged watching the magic unfold. &amp;ldquo;But how do we tell it to look for more than one instance, BATCHman? How does it know it is lowercase?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Presently it doesn&amp;rsquo;t, but it will if we add more parameters to our &lt;b&gt;Select-String&lt;/b&gt;. One is -&lt;i&gt;allmatches&lt;/i&gt; in case there is more than one instance per line. The other is -&lt;i&gt;casesensitive&lt;/i&gt; because &lt;b&gt;Select-String&lt;/b&gt; by default just does a &lt;i&gt;&amp;ndash;match&lt;/i&gt; which doesn&amp;rsquo;t care about uppercase or lowercase.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-CONTENT C:\EVILCLUE.TXT | SELECT-STRING &amp;lsquo;\b[a-z]{2,}&amp;rsquo; &amp;ndash;casesensitive &amp;ndash;allmatches&lt;/p&gt;
&lt;p style="padding-left:60px;"&gt;Evil may Come And Evil May Go &lt;br /&gt;The BATCHman Will Seek, be Fast Or Be Slow &lt;br /&gt;But Soon On the Day The pass It Must Be &lt;br /&gt;The word Should He Say, To Not Set Them Free &lt;br /&gt;is The BATCHman Too Smart, Or Is He Not Bright? &lt;br /&gt;under The Stars And Under the Light! &lt;br /&gt;The key We Shall See, Unlocking This Clue &lt;br /&gt;Will chain Them All Down, Or Let Them Run Through&lt;/p&gt;
&lt;p&gt;Cmdlet looked and laughed. &amp;ldquo;Holy foot in mouth! The output is the same!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The BATCHman smiled. &amp;ldquo;Not quite. If we run &lt;b&gt;Get-Member&lt;/b&gt; against this output, you&amp;rsquo;ll see something different.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-CONTENT C:\EVILCLUE.TXT | SELECT-STRING &amp;lsquo;\b[a-z]{2,}&amp;rsquo; &amp;ndash;casesensitive &amp;ndash;allmatches | GET-MEMBER&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/3580.HSG_2D00_9_2D00_2_2D00_11_2D00_3.jpg"&gt;&lt;img border="0" alt="" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/3580.HSG_2D00_9_2D00_2_2D00_11_2D00_3.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;This, Cmdlet, is not just a string. We can see there are properties such as &lt;i&gt;Matches&lt;/i&gt;. If we were to look at the properties of &lt;i&gt;Matches&lt;/i&gt;, we mind find something interesting.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-CONTENT C:\EVILCLUE.TXT | SELECT-STRING &amp;lsquo;\b[a-z]{2,}&amp;rsquo; &amp;ndash;casesensitive &amp;ndash;allmatches | SELECT-OBJECT Matches&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/2337.HSG_2D00_9_2D00_2_2D00_11_2D00_4.jpg"&gt;&lt;img style="border:0px;" title="Image of matches" alt="Image of matches" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/2337.HSG_2D00_9_2D00_2_2D00_11_2D00_4.jpg" width="150" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Holy obvious! Do you mean&amp;hellip;&amp;rdquo; looking to his left Cmdlet lifts the keychain to the old cages. A Big envelope with the words &amp;ldquo;^[Dr!Regex]^&amp;rdquo; is written on it. He bites it open and his mouth drops sullenly.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;What is it, Cmdlet?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Another clue. Awww, come &lt;i&gt;on&lt;/i&gt;!!!&amp;rdquo; Cmdlet stomps about like a little child having a hissy fit showing the new clue to BATCHman.&lt;/p&gt;
&lt;p&gt;Remove ME now and unlock the clue&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;lsquo;meHeymeheymewemearemethemescriptmemonkeesmeandmepeoplemesaymewemearemescriptingmeawayme&amp;rsquo;&lt;/p&gt;
&lt;p&gt;BATCHman looks. &amp;ldquo;I&amp;rsquo;m seeing an awful lot of &lt;i&gt;ME&lt;/i&gt; in this particular line. I will bet we could just use a &lt;i&gt;&amp;ndash;replace&lt;/i&gt; on it!&lt;/p&gt;
&lt;p&gt;&amp;ldquo;What&amp;rsquo;s that?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Seating himself down in front of the Windows PowerShell console, he explains. &amp;ldquo;&lt;i&gt;Replace&lt;/i&gt; is another part of regular expressions where we can replace one thing with another.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;lsquo;meHeymeheymewemearemethemescriptmemonkeesmeandmepeoplemesaymewemearemescriptingmeawayme&amp;rsquo; &amp;ndash;replace &amp;lsquo;me&amp;rsquo;,&amp;rsquo;&amp;rsquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;That will replace every reference of &lt;b&gt;me&lt;/b&gt; with nothing, which gives us this result.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Heyheywearethescriptmonkeesandpeoplesaywearescriptingaway&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Cmdlet, please try this password on the Chubb security system. I&amp;rsquo;m sure you&amp;rsquo;ll find it works; just press the &lt;b&gt;Lock All Cages&lt;/b&gt; button.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Soon echoing through the Redmond Zoo, massive sounds of &lt;b&gt;*KLANG*&lt;/b&gt; echo throughout with the odd *&lt;b&gt;yelp&lt;/b&gt;* as the occasional finger gets pinched on closing doors.&lt;/p&gt;
&lt;p&gt;With one loud *&lt;b&gt;THUD&lt;/b&gt;*, Dr. Regex falls into bushes below. &amp;ldquo;Waaaaihihghghhgih!!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The keeper of the Redmond Zoo looks up. &amp;ldquo;Oh, BATCHman! How can ever thank you?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Easy, good citizen. One, do not put your master security password under a set of keys to the Monkey House and&amp;hellip;do you have something I could scrape my shoes on? I think I stepped on something near the cages.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks, Sean, for another exciting episode of BATCHman! Join us tomorrow for Episode 5.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3449490" width="1" height="1" alt="" /&gt;</description></item><item><title>BATCHman Faces the Distractful Poker and Recovers Deleted Active Directory Items</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2011/08/28/batchman-faces-the-distractful-poker-and-recovers-deleted-active-directory-items.aspx</link><pubDate>Sun, 28 Aug 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:12044</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;b&gt;Summary&lt;/b&gt;: In today&amp;rsquo;s gripping episode, BATCHman squares off with the Distractful Poker and recovers items deleted from Active Directory Domain Services using Windows PowerShell.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy Ed Wilson here. Windows PowerShell MVP &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/windows+powershell/guest+blogger/batchman/"&gt;Sean Kearney&lt;/a&gt; is with us again today with part 3 of the BATCHman series.&lt;/p&gt;
&lt;p&gt;&lt;img style="border:0px;" title="BATCHman and Cmdlet graphic" alt="BATCHman and Cmdlet graphic" src="http://i.technet.microsoft.com/bb410849.Batchman_Icon_05_bluebatchman_082511(en-us,MSDN.10).png" /&gt;&lt;/p&gt;
&lt;p&gt;Whenever trouble happens in systems and people will call, &lt;br /&gt;And darkness rolls out causing your fall, &lt;br /&gt;Creatures of bits roam in the night, &lt;br /&gt;Shine to the sky, the bright bluish light,&lt;/p&gt;
&lt;p&gt;and call to&amp;hellip;BATCHMAN!&lt;/p&gt;
&lt;p&gt;&amp;hellip;and, oh yes, his sidekick Cmdlet too.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In Today&amp;rsquo;s Episode: BATCHman encounters the Distractful Poker&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A travesty has hit Redmond City! The mayor and his staff are unable to log in to Active Directory Domain Services!&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Quick! Get the chief to fire up the BATCHSignal and call BATCHman! We need his help now!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Shining up to the sky, a gleaming Windows PowerShell signal cutting through the sky and the flight patterns of a few seagulls&amp;mdash;the BATCHSignal! Within moments the WinMobile pulls up precariously holding up BATCHman and Cmdlet. The Mayor looks over. &amp;ldquo;Just how do the pair of you fit on that?&amp;rdquo; &amp;ldquo;Very carefully,&amp;rdquo; quips BATCHman. &amp;ldquo;So what has happened here today?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Oh BATCHman!&amp;rdquo; the mayor sobbed. &amp;ldquo;It was the Poker! He came behind the systems administrator, poked him in the side, distracted him, and deleted our user accounts! We can&amp;rsquo;t get into the system to issue paychecks to any of our staff! If we don&amp;rsquo;t solve this soon, we&amp;rsquo;ll have a major disaster on our hands!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Holy irritants, BATCHman! Not the Poker! Why the last time he was around&amp;hellip;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Yes, Cmdlet, I know the story. Clippy was born. The Poker is truly a cruel one. But never mind that. Mayor! Quick take make to your datacenter! We don&amp;rsquo;t have one second to spare.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;In moments, BATCHman and Cmdlet stood before a console. BATCHman thought, &amp;ldquo;I could go dig up tapes and do an authoritative restore, but time is of the essence.&amp;rdquo; Quickly, he spun on his feet.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Mayor, did you upgrade to Windows Server 2008 R2 as we suggested last time I chatted with you?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Why, yes. Yes, I think we did, BATCHman, but why do you ask?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman smiled. &amp;ldquo;if we&amp;rsquo;re lucky, your administrator enabled the Active Directory Recycle Bin. I can check in moments.&amp;rdquo; On one of the Windows Server 2000 R2 domain controllers, BATCHman typed:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-ADOPTIONALFEATURE &amp;lsquo;Recycle Bin Feature&amp;rsquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;The results of this on the screen, Cmdlet, not only tell us about the feature, but also about what scope it applies to. By default, in a system where it&amp;rsquo;s not enabled, the &lt;b&gt;EnabledScopes&lt;/b&gt; property will have no value.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/4578.hsg_2D00_8_2D00_28_2D00_11_2D00_2.jpg"&gt;&lt;img style="border:0px;" title="Image of EnabledScopes property" alt="Image of EnabledScopes property" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/4578.hsg_2D00_8_2D00_28_2D00_11_2D00_2.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;As we can see, it &lt;i&gt;has&lt;/i&gt; been enabled here. So now, what we need to do is determine just how much damage has been done by this evil villain. With the &lt;b&gt;ActiveDirectory&lt;/b&gt; module, we can key this in to show all objects in Active Directory, including anything that is in the Active Directory Recycle Bin.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Get-ADObject -filter * &amp;ndash;IncludeDeletedObjects&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;But BATCHman!&amp;rdquo; Cmdlet spoke up. &amp;ldquo;Wouldn&amp;rsquo;t that be too much? What if we&amp;rsquo;re dealing with 50,000 objects? There must be a way to only show what was deleted!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman nodded. &amp;ldquo;Correct. So now if we run the GET-MEMBER cmdlet against the output like this&amp;hellip;&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Get-ADObject -filter * &amp;ndash;IncludeDeletedObjects | GET-MEMBER&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;&amp;hellip;we&amp;rsquo;ll see there is a property called &lt;strong&gt;DELETED&lt;/strong&gt; which contains a Boolean &lt;b&gt;TRUE&lt;/b&gt; if that value is deleted. For this, we will add a filter to the statement.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Get-ADObject &amp;ndash;filter &amp;lsquo;Deleted &amp;ndash;eq $TRUE&amp;rsquo; &amp;ndash;IncludeDeletedObjects&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Now we can see only deleted items in Active Directory so&amp;hellip;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Holy undo, BATCHman! Is there a restore we can just pipe the output to?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman nodded. &amp;ldquo;Yes. But what we need to do is restore the tree first. At this point, let&amp;rsquo;s pipe the output into the &lt;b&gt;Out-GridView&lt;/b&gt; cmdlet to have an easier way of viewing the data.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Get-ADObject &amp;ndash;filter &amp;lsquo;Deleted &amp;ndash;eq $TRUE&amp;rsquo; &amp;ndash;IncludeDeletedObjects | OUT-GRIDVIEW&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/1346.hsg_2D00_8_2D00_28_2D00_11_2D00_3.png"&gt;&lt;img border="0" alt="" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/1346.hsg_2D00_8_2D00_28_2D00_11_2D00_3.png" /&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BATCHman cautiously examined the list. &amp;ldquo;It appears we should be able to pull out all members of the tree by filtering on &lt;b&gt;ObjectClass&lt;/b&gt; and pulling down those with the property &lt;b&gt;OrganizationalUnit&lt;/b&gt;. So we just need to add an extra filter to our statement.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Get-ADObject &amp;ndash;filter &amp;lsquo;Deleted &amp;ndash;eq $TRUE &amp;ndash;and Objectclass &amp;ndash;eq &amp;ldquo;OrganizationalUnit&amp;rdquo;&amp;rsquo; &amp;ndash;IncludeDeletedObjects | OUT-GRIDVIEW&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Now all we need to do is pipe this output into the &lt;b&gt;Restore ADObject&lt;/b&gt; to get the tree back.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Get-ADObject &amp;ndash;filter &amp;lsquo;Deleted &amp;ndash;eq $TRUE &amp;ndash;and Objectclass &amp;ndash;eq &amp;ldquo;OrganizationalUnit&amp;rdquo;&amp;rsquo; &amp;ndash;IncludeDeletedObjects | RESTORE-ADOBJECT&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Now with the tree restored, we can just restore the rest of the objects remaining using a simpler statement because we&amp;rsquo;ve already restored the tree. The rest of the objects we have are probably users, so we can drop the second filter and just restore.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Get-ADObject &amp;ndash;filter &amp;lsquo;Deleted &amp;ndash;eq $TRUE &amp;ndash;and Objectclass&amp;rsquo; &amp;ndash;IncludeDeletedObjects | RESTORE-ADOBJECT&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;In moments, the task was complete. &amp;ldquo;Cmdlet, have somebody try to log in to the system!&amp;rdquo; The mayor quickly logged in to verify all worked well. Quickly he called up the accounting department to let them know they could log in to the systems. Paychecks would be out today!&lt;/p&gt;
&lt;p&gt;&amp;ldquo;BATCHman! How can we ever thank you?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Just keep doing things the way you are with Windows PowerShell: it was the true superhero today!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you, Sean, for today&amp;rsquo;s spell-binding article. Sean will be back next weekend with the concluding episodes of BATCHman. Same BATCHtime, same BATCHchannel.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3447953" width="1" height="1" alt="" /&gt;</description></item><item><title>BATCHman Uses PowerShell to Battle the Dread Madame CAT File</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2011/08/27/batchman-uses-powershell-to-battle-the-dread-madame-cat-file.aspx</link><pubDate>Sat, 27 Aug 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:12032</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;: In today&amp;rsquo;s episode, intrepid BATCHman uses Windows PowerShell to battle the dreaded Madame CAT file&amp;mdash;and the fur really flies.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy Ed Wilson here. Windows PowerShell MVP &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/windows+powershell/guest+blogger/batchman/"&gt;Sean Kearney&lt;/a&gt; returns today for part 2 in his BATCHman series.&lt;/p&gt;
&lt;p&gt;&lt;img style="border:0px;" title="BATCHman and Cmdlet graphic" alt="BATCHman and Cmdlet graphic" src="http://i.technet.microsoft.com/bb410849.Batchman_Icon_05_bluebatchman_082511(en-us,MSDN.10).png" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Deep in the most unforgiving lines of code, a new superhero emerges to bind the illogical, bring peace to the unfathomable binary things in the night, and seek justice where none can be found.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s your friend and mine, BATCHman!&lt;/p&gt;
&lt;p&gt;&amp;hellip;.and his sidekick, Boy Blunder Cmdlet.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In Today&amp;rsquo;s Episode: BATCHman encounters the Dreaded Madame CAT file&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Oh, no! The JobsBlog Team has been victimized by Madame CAT file! Madame CAT file loves to do &lt;i&gt;nothing&lt;/i&gt; but rename files and place CAT all over the place. Today, she has attacked the folder structure of Microsoft Office leaving the JobsBlog Team helpless!&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Oh, how will we ever be able to review the resumes now? No Outlook! No Word! All of these resumes trapped! Resources untouched! Oh, where is BATCHman? Help us!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Flying out of nowhere in a flurry of SMS packets and Gorilla Glass, and arriving with a classic &amp;ldquo;TADA&amp;rdquo; wav file from Windows 3.1, it&amp;rsquo;s..it&amp;rsquo;s&amp;hellip;&lt;/p&gt;
&lt;p&gt;The truly dynamic (as opposed to static) BATCHman and Cmdlet!&lt;/p&gt;
&lt;p&gt;&amp;ldquo;BATCHman! Thank goodness you&amp;rsquo;re here! We have millions of resumes to go through and Madame CAT file has rendered us helpless! Our copies of Microsoft Office are covered with nothing but the word &amp;ldquo;CAT.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Holy kitty litter, BATCHman!&amp;rdquo; bursts out Cmdlet. &amp;ldquo;What can we do?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman quickly assesses the situation. There are two options he foresees.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Well, Cmdlet, we could just do a System Restore to before Madame CAT file released her claws, but that will take time on all these computers. We need to restore the entire Jobs Blog to action quickly! If we aren&amp;rsquo;t careful, some fool might post over 8,000 resumes to the system and overload the team! It&amp;rsquo;s happened once before, and we just can&amp;rsquo;t take a chance!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman thinks for a moment. &amp;ldquo;You know, I think we can take a shot at undoing this. Let&amp;rsquo;s see just how much damage that villain really did. I know Windows stores additional properties about certain key files, such as DLLs and EXEs, in the file itself.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Cmdlet looks up. &amp;ldquo;Really? Zowie! How do we pull something like that up?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman looks at an afffected file:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-CHILDITEM C:\Program Files\Microsoft Office\Office14\CATWORDMEOW.EXE&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;As we can see, Cmdlet, the file name has been completely tampered with, but if we run this against the Get-Member cmdlet, we can see there are additional properties available to us:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-CHILDITEM C:\Program Files\Microsoft Office\Office14\CATWORDMEOW.EXE | GET-MEMBER&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;I can see we have a property called &lt;b&gt;VersionInfo&lt;/b&gt;. My scripting sense is tingling here. If we were to access this with a &lt;strong&gt;Select-Object&lt;/strong&gt; cmdlet and see what it looks like&amp;hellip;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5700.hsg_2D00_8_2D00_27_2D00_11_2D00_1.jpg"&gt;&lt;img style="border:0px;" title="Image of VersionInfo property" alt="Image of VersionInfo property" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5700.hsg_2D00_8_2D00_27_2D00_11_2D00_1.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Holy Harry Houdini, BATCHman! There&amp;rsquo;s the file name hidden in the &lt;b&gt;Filename&lt;/b&gt; properties!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Yes, Boy Blunder, but we&amp;rsquo;ll have to dig a bit further. So let&amp;rsquo;s access the property directly to find the name of the property it can be referenced by. We could run the Get-Member cmdlet against it like this.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;(GET-CHILDITEM C:\Program Files\Microsoft Office\Office14\CATWORDMEOW.EXE).VersionInfo | GET-MEMBER&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;But let&amp;rsquo;s see if the information is easily accessible. Windows PowerShell has a tendency to try and make this easier.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;(GET-CHILDITEM C:\Program Files\Microsoft Office\Office14\CATWORDMEOW.EXE).VersionInfo&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7217.hsg_2D00_8_2D00_27_2D00_11_2D00_2.jpg"&gt;&lt;img border="0" alt="" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7217.hsg_2D00_8_2D00_27_2D00_11_2D00_2.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Cmdlet just about dropped a process when he saw the results. &amp;ldquo;BATCHman! So if I were to type the &lt;b&gt;Filename&lt;/b&gt; property&amp;hellip;&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;(GET-CHILDITEM C:\Program Files\Microsoft Office\Office14\CATWORDMEOW.EXE).VersionInfo.Filename&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/2313.hsg_2D00_8_2D00_27_2D00_11_2D00_3.jpg"&gt;&lt;img border="0" alt="" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/2313.hsg_2D00_8_2D00_27_2D00_11_2D00_3.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;His heart sank. &amp;ldquo;Oh, no! It&amp;rsquo;s the same! AIHGAIHGIAHGHIHAIGHIH!!!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Calm down, little Cmdlet. There are other properties. Sometimes just piping the output to the &lt;b&gt;Format-List&lt;/b&gt; cmdlet will reveal them in a more useful manner. Remember, we&amp;rsquo;re looking at the &lt;i&gt;default&lt;/i&gt; output in Windows PowerShell.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;(GET-CHILDITEM C:\Program Files\Microsoft Office\Office14\CATWORDMEOW.EXE).VersionInfo | FORMAT-LIST&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/0574.hsg_2D00_8_2D00_27_2D00_11_2D00_4.jpg"&gt;&lt;img border="0" alt="" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/0574.hsg_2D00_8_2D00_27_2D00_11_2D00_4.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;So although you are correct in that the &lt;b&gt;Filename&lt;/b&gt; shows the current file name, there is actually a property called &lt;b&gt;OriginalFileName&lt;/b&gt;, which has been untouched by our Evildoer, and we can access it like this.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;(GET-CHILDITEM C:\Program Files\Microsoft Office\Office14\CATWORDMEOW.EXE).VersionInfo.OriginalFileName&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;BATCHman! Do you mean we could just check the properties of the .dll files and .exe files and possibly just rename them to the original? Even Madame CAT file made the name unrecognizable?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Patting Cmdlet on the back he smiled. &amp;ldquo;That&amp;rsquo;s exactly what I mean!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Then Cmdlet sighed. &amp;ldquo;BATCHman, that&amp;rsquo;s going to be a horribly complicated script! To pull up all those .dll and .exe files, analyze them, rename them, examine them&amp;hellip;,&amp;rdquo; he rambled on.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;You forget, my young friend, that with Windows PowerShell, to pull such a list we simply need to specify the file extensions we want to include and recurse like this.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-CHILDITEM C:\Program Files\Microsoft Office\Office14\ &amp;ndash;include *.exe, *.dll &amp;ndash;recurse&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Yes I know! But how can we just rename them? To properly do that, we need the file path, the drive letter!&amp;rdquo; Cmdlet began to sob &amp;ldquo;WE&amp;rsquo;RE DOOOOOMED! DOOMED! DOOOOOOOOMED!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;We could just run a &lt;b&gt;Foreach&lt;/b&gt;, pull up the properties, and &lt;b&gt;Rename&lt;/b&gt; the bad file name with itself like this, Cmdlet,&amp;rdquo; he stated calmly.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-CHILDITEM C:\Program Files\Microsoft Office\Office14\ &amp;ndash;include *.exe, *.dll &amp;ndash;recurse | Foreach { Rename-item $_.Fullname &amp;ndash;newname $_.OriginalFilename }&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;B-b-but, BATCHman! There&amp;rsquo;s more than 200 files we could be affecting! What if we ruin them? What if we do something horrendously bad? What if your code destroys everything?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Funny you should mention the &amp;lsquo;what if.&amp;rdquo; I was thinking that very same thing. That&amp;rsquo;s why Windows PowerShell has a parameter called &lt;i&gt;&amp;ndash;whatif&lt;/i&gt; that is generally provided with any cmdlet that could make a change to the system. We just add it on like this and execute the code.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;GET-CHILDITEM C:\Program Files\Microsoft Office\Office14\ &amp;ndash;include *.exe, *.dll &amp;ndash;recurse | Foreach { Rename-item $_.Fullname &amp;ndash;newname $_.OriginalFilename -whatif}&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Cmdlet watched in amazement as each line was executed in the following fashion:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;What if: Performing operation &amp;quot;Rename File&amp;quot; on Target &amp;quot;Item: C:\Program Files\Microsoft Office\Office14\MCATPUB.EXE Destination: C:\Program Files\Microsoft Office\Office14\MSPUB.EXE&amp;quot;.&lt;br /&gt;What if: Performing operation &amp;quot;Rename File&amp;quot; on Target &amp;quot;Item: C:\Program Files\Microsoft Office\Office14\MSCAT32.EXE Destination: C:\Program Files\Microsoft Office\Office14\MSQRY32.EXE&amp;quot;.&lt;br /&gt;What if: Performing operation &amp;quot;Rename File&amp;quot; on Target &amp;quot;Item: C:\Program Files\Microsoft Office\Office14\MSCATEDIT.DLL Destination: C:\Program Files\Microsoft Office\Office14\MSRTEDIT.DLL&amp;quot;.&lt;br /&gt;What if: Performing operation &amp;quot;Rename File&amp;quot; on Target &amp;quot;Item: C:\Program Files\Microsoft Office\Office14\CATWORDMEOW.EXE Destination: C:\Program Files\Microsoft Office\Office14\WINWORD.EXE&amp;quot;.&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;You see? With Windows PowerShell, we have a built-in way to test without breaking anything. As we can see, it appears this script should work. I&amp;rsquo;ll remove the &lt;i&gt;&amp;ndash;whatif&lt;/i&gt; parameter and execute as normal.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Moments later, a system was recovered. All of the CAT litter was gone!&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Now quickly, Cmdlet! Take this USB key, run Windows PowerShell with administrative rights, and execute this code on each affected machine!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;In a matter of minutes the entire team was restored to productivity!&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Now keep in mind, Cmdlet, that this was a break/fix&amp;mdash;a good one but a brake/fix nonetheless. We should speak to IT about having System Restore run on these machines later. But for the moment, we&amp;rsquo;re good!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Oh, BATCHman! How can we ever thank you?&amp;rdquo; burst out the JobsBlog Team.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Easy! Always trust in Windows PowerShell and try not to let any more CATs in the office with local administrative access. BATCHman&amp;hellip;AWAY!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you, Sean. Everyone come back tomorrow for part 3. Same BATCHtime, same BATCHchannel.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3447975" width="1" height="1" alt="" /&gt;</description></item><item><title>BATCHman Uses PowerShell to Battle the Evil Mr. Freeze-Process</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2011/08/26/batchman-uses-powershell-to-battle-the-evil-mr-freeze-process.aspx</link><pubDate>Fri, 26 Aug 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:12013</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;: A new superhero uses Windows PowerShell for good. He is BATCHman, and today he battles Mr. Freeze-Process.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img title="Hey, Scripting Guy! Question" border="0" alt="Hey, Scripting Guy! Question" align="left" src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/q-sm.jpg" width="34" height="34" /&gt;Hey, Scripting Guy! I know there are the Scripting Guy and Dr. Scripto, but are there any &lt;i&gt;real&lt;/i&gt; scripting superheroes?&lt;/p&gt;
&lt;p&gt;&amp;mdash;SH&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img title="Hey, Scripting Guy! Answer" border="0" alt="Hey, Scripting Guy! Answer" align="left" src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/a-sm.jpg" width="34" height="34" /&gt;Hello SH,&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy Ed Wilson here. Today is part 1 of a multipart series written by Windows PowerShell MVP Sean Kearney. Read &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/windows+powershell/guest+blogger/batchman/"&gt;his other posts&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The one superhero to whom all others pale in comparison is faster than that so-called Flash guy with his efficiency of code and able to leap past unbelievable expectations of clients (more than SomewhatSuper Guy). He has the endurance of an all-night developer trapped in a last-minute bug fix and the strength of an IT pro standing in an overheating datacenter.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s your friend and mine: BATCHman!&lt;/p&gt;
&lt;p&gt;&amp;hellip;and his Boy Blunder Cmdlet.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In Today&amp;rsquo;s Episode, BATCHman Encounters Mr. Freeze-Process!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We find today the evil villain Mr. Freeze-Process&amp;mdash;once a harmless data entry clerk known as VIC Twennie, who&amp;rsquo;s mind was so twisted he tried translating Hollerith cards to English&amp;mdash;hovering over his victim, philanthropist Bill Gates.&lt;/p&gt;
&lt;p&gt;&amp;rdquo;Buah ha ha ha haaa! I have you now! Your entire laptop held prisoner by my constantly spawning processes! A screen flooded in Notepad! A-ha! You will never get that email out to the world now with that newly discovered cure! Now quickly sign! Sign! Sign your autograph on every sheet of paper on this skid! I will make billions selling it on online auction sites!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Mr. Gates looks to the ground sullenly. &amp;ldquo;Oh, if only BATCHman were here to save me from this diabolic and bad-acting villain!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;***Meanwhile back in the BATCHcave!***&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Cmdlet, my scripting sense is tingly! I sense, I sense trouble! Quickly! To the WinMobile!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;***Moments later with minimal explanation or plot! ***&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Oh, thank goodness you&amp;rsquo;re here, BATCHman! The Evil Mr. Freeze-Process has tied up my laptop with an application that constantly launches copies of Notepad. My CPU is pegged and I need to get a truly important email message out!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman disposes his faithful sidekick to keep Mr. Freeze-Process busy by interviewing him for the fake Villain of the Year Award. Quickly he assesses the problem. There is a parent process spawning multiple copies of Notepad. &amp;ldquo;This is a job for Windows PowerShell!&amp;rdquo; he blurts dramatically.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;First, we must kill off most of these applications. Using Windows PowerShell, I can run the Get-Process cmdlet to find all the copies of it. I will store those results in a variable so that I don&amp;rsquo;t fill up the screen.&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;$BADPROCESSES=GET-PROCESS NOTEPAD&lt;/em&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Now I can use the Stop-Process cmdlet. But rather than trying to stop them one at a time, I can just pipe the entire list in!&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;$BADPROCESSES | STOP-PROCESS&lt;/em&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;By this time the Boy Blunder has returned, having bored Mr. Freeze-Process to sleep.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Holy echo, BATCHman! They&amp;rsquo;re still appearing!&amp;rdquo; True enough, the Boy Blunder was right! Notepad kept appearing! &amp;ldquo;Zoinks! I almost forgot about the parent process! What a diabolic villain!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Quickly, our hero thinks to himself. &amp;ldquo;I must find the newest process that launched just before all these child processes! *SNAP* Of course!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman runs Get-Member against Get-Process:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;GET-PROCESS | GET-MEMBER&lt;/em&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;He finds there is a property called &lt;b&gt;Starttime&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;I shall run Get-Process, and not show any Notepad in the list. Then I shall run the output through Sort-Object based on the &lt;b&gt;Starttime&lt;/b&gt; to put the most recent ones near the top. Odds are that Mr. Freeze-Process&amp;rsquo; application is one of the last ones launched!&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;GET-PROCESS | Where { $_.Name &amp;ndash;ne &amp;lsquo;NOTEPAD&amp;rsquo;} | Sort-object Starttime&lt;/em&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;But a problem appears in the output! &amp;ldquo;Holy unclear answers, BATCHman! Look!&amp;rdquo; bursts out Cmdlet.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7433.HSG_2D00_8_2D00_26_2D00_11_2D00_1.jpg"&gt;&lt;img style="border:0px;" title="Image of issue in output" alt="Image of issue in output" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7433.HSG_2D00_8_2D00_26_2D00_11_2D00_1.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The BATCHman, never fazed, realizes not all processes such as system processes can have their properties read by the user. We can have this ignored in the output to make it clearer to read by adjusting the &lt;b&gt;ErrorAction&lt;/b&gt; value in the line:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;GET-PROCESS | Where { $_.Name &amp;ndash;ne &amp;lsquo;NOTEPAD&amp;rsquo;} | Sort-object Starttime &amp;ndash;erroraction &amp;lsquo;SilentlyContinue&amp;rsquo;&lt;/em&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Much better!&amp;rdquo; exclaims BATCHman, &amp;ldquo;but I really only need the most recent processes.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;BATCHman,&amp;rdquo; Cmdlet pokes in, &amp;ldquo;could we run all of this through &lt;b&gt;Select-Object&lt;/b&gt; and just take the top 3? We should have an easier time spotting parent applications launching all these vile Notepads!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Of course, Boy Blunder! Excellent work! We&amp;rsquo;ll use &lt;b&gt;Select-Object&lt;/b&gt; and show the last 3 items in the process list!&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;GET-PROCESS | Where { $_.Name &amp;ndash;ne &amp;lsquo;NOTEPAD&amp;rsquo;} | Sort-Object Starttime &amp;ndash;erroraction &amp;lsquo;SilentlyContinue&amp;rsquo; | Select-Object &amp;ndash;Last 3&lt;/em&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/6724.HSG_2D00_8_2D00_26_2D00_11_2D00_2.jpg"&gt;&lt;img style="border:0px;" title="Image of output of last three items in process list" alt="Image of output of last three items in process list" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/6724.HSG_2D00_8_2D00_26_2D00_11_2D00_2.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Now, Cmdlet, let&amp;rsquo;s strike that parent process! Taste BATCH Justice, EvilDoerProgram!&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;GET-PROCESS EvilDoerProgram | STOP-PROCESS &amp;ndash;force&lt;/em&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Let&amp;rsquo;s crush those remaining Notepad applications once more to get Mr. Gates back to his ability to save the world!&amp;rdquo;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;GET-PROCESS NOTEPAD | STOP-PROCESS &amp;ndash;force&lt;/em&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;In moments, the screen quiets down and the laptop returns to normal. Mr. Gates quickly clicks &lt;b&gt;Send&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Holy vanishing process, BATCHman! It appears the villain has run off!&amp;rdquo; screams Cmdlet.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;As evildoers always will, Cmdlet.&amp;rdquo; smiles BATCHman.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Thank you BATCHman! How can I ever thank you?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Just keep doing what you do best, saving the world.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;BATCHman shakes Mr. Gates&amp;rsquo;s hand and is about to step onto the WinMobile when Cmdlet starts tugging on his cape.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Yes, Cmdlet?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;&amp;hellip;pssst&amp;hellip;pssst&amp;hellip;&amp;hellip;psssst&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Ah, I see. Mr. Gates, Cmdlet would like to get your autograph.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Why sure! There&amp;rsquo;s about five hundred in that pile over there.&amp;rdquo; Mr. Gates points at the former skid of paper provided by the Evil Mr. Freeze-Process&lt;/p&gt;
&lt;p&gt;They all laugh as Cmdlet quickly executes his newly written advanced function &lt;b&gt;GET-AUTOGRAPH | OUT-SAFE&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks, Sean! Join us tomorrow for part 2 of the amazing adventures of BATCHman. Same BATCHtime, Same BATCHchannel.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3448154" width="1" height="1" alt="" /&gt;</description></item></channel></rss>