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

<channel>
	<title>musc@&#62; $daniele.rant &#124; Out-Blog &#187; PowerShell</title>
	<atom:link href="http://www.muscetta.com/category/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.muscetta.com</link>
	<description>Superior Dedication - If you try hard enough, you might even get it to work.</description>
	<lastBuildDate>Sun, 18 Jul 2010 15:22:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>OpsMgr Eventlog analysis with Powershell</title>
		<link>http://www.muscetta.com/2009/12/16/opsmgr-eventlog-analysis-with-powershell/</link>
		<comments>http://www.muscetta.com/2009/12/16/opsmgr-eventlog-analysis-with-powershell/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 10:17:35 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[OpsMgr2007]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[System Center Operations Manager 2007]]></category>
		<category><![CDATA[analysis]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[eventlog]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/?p=489</guid>
		<description><![CDATA[The following technique should already be understood by any powersheller. Here we focus on Operations Manager log entries, even if the data mining technique shows is entirely possibly – and encouraged &#8211; with any other event log. Let’s start by getting our eventlog into a variable called $evt: PS&#160; &#62;&#62; $evt = Get-Eventlog “Operations Manager” [...]<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p>The following technique should already be understood by any powersheller. Here we focus on Operations Manager log entries, even if the data mining technique shows is entirely possibly – and encouraged <img src='http://www.muscetta.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  &#8211; with any other event log.</p>
<p>Let’s start by getting our eventlog into a variable called $evt:</p>
<p><strong>PS&#160; &gt;&gt; $evt = Get-Eventlog “Operations Manager”</strong></p>
<p>The above only works locally in POSH v1.</p>
<p>In POSH v2 you can go remotely by using the “-computername” parameter:</p>
<p><strong>PS&#160; &gt;&gt; $evt = Get-Eventlog “Operations Manager” –computername RMS.domain.com</strong></p>
<p>Anyhow, you can get to this remotely also in POSHv1 with this other more “dotNET-tish” syntax:</p>
<p><strong>PS &gt;&gt; $evt = (New-Object System.Diagnostics.Eventlog -ArgumentList &quot;Operations Manager&quot;).get_Entries()</strong></p>
<p>you could even export this (or any of the above) to a CLIXML file:</p>
<p><strong>PS &gt;&gt; (New-Object System.Diagnostics.Eventlog -ArgumentList &quot;Operations Manager&quot;).get_Entries() | export-clixml -path c:\evt\Evt-OpsMgr-RMS.MYDOMAIN.COM.xml</strong></p>
<p>and then you could reload your eventlog to another machine:</p>
<p><strong>PS&#160; &gt;&gt; $evt = import-clixml c:\evt\Evt-OpsMgr-RMS.MYDOMAIN.COM.xml</strong>     </p>
<p>whatever way you used to populate your $evt&#160; variable, be it from a “live” eventlog or by re-importing it from XML, you can then start analyzing it:</p>
<p><strong>PS&#160; &gt;&gt; $evt | where {$_.Entrytype -match &quot;Error&quot;} | select EventId,Source,Message | group eventid </strong></p>
<p>Count Name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Group    <br />&#8212;&#8211; &#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8211;     <br />1510 4509&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=4509; Source=HealthService; Message=The constructor for the managed module type &quot;Microsoft.EnterpriseManagement.Mom.DatabaseQueryModules.GroupCalculatio.     <br />&#160;&#160; 15 20022&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=20022; Source=OpsMgr Connector; Message=The health service {7B0E947B-2055&#8230;     <br />&#160;&#160;&#160; 3 26319&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=26319; Source=OpsMgr SDK Service; Message=An exception was thrown while p&#8230;     <br />&#160;&#160;&#160; 1 4512&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=4512; Source=HealthService; Message=Converting data batch to XML failed w&#8230; </p>
<p>the above is functionally identical to the following:</p>
<p><strong>PS&#160; &gt;&gt; $evt | where {$_.Entrytype -eq 1} | select EventID,Source,Message | group eventid </strong></p>
<p>Count Name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Group    <br />&#8212;&#8211; &#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8211;     <br />1510 4509&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=4509; Source=HealthService; Message=The constructor for the managed modul&#8230;     <br />&#160;&#160; 15 20022&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=20022; Source=OpsMgr Connector; Message=The health service {7B0E947B-2055&#8230;     <br />&#160;&#160;&#160; 3 26319&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=26319; Source=OpsMgr SDK Service; Message=An exception was thrown while p&#8230;     <br />&#160;&#160;&#160; 1 4512&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=4512; Source=HealthService; Message=Converting data batch to XML failed w&#8230; </p>
<p>Note that Eventlog Entries’ type is an ENUM that has values of 0,1,2 – similarly to OpsMgr health states – but beware that their order is not the same, as shown in the following table:</p>
<table border="1" cellspacing="0" cellpadding="2" width="342">
<tbody>
<tr>
<td valign="top" width="71"><strong>Code</strong></td>
<td valign="top" width="137"><strong>OpsMgr States</strong></td>
<td valign="top" width="132"><strong>Events EntryType</strong></td>
</tr>
<tr>
<td valign="top" width="71">0</td>
<td valign="top" width="137">Not Monitored</td>
<td valign="top" width="132">Information</td>
</tr>
<tr>
<td valign="top" width="71">1</td>
<td valign="top" width="137">Success</td>
<td valign="top" width="132">Error</td>
</tr>
<tr>
<td valign="top" width="71">2</td>
<td valign="top" width="137">Warning</td>
<td valign="top" width="132">Warning</td>
</tr>
<tr>
<td valign="top" width="71">3</td>
<td valign="top" width="137">Critical</td>
<td valign="top" width="132">&#8211;</td>
</tr>
</tbody>
</table>
<p>Let’s now look at Information Events (Entrytype –eq 0)</p>
<p><strong>PS&#160; &gt;&gt; $evt | where {$_.Entrytype -eq 0} | select EventID,Source,Message | group eventid </strong></p>
<p>Count Name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Group    <br />&#8212;&#8211; &#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8211;     <br />4135 2110&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=2110; Source=HealthService; Message=Health Service successfully transferr&#8230;     <br />1548 21025&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=21025; Source=OpsMgr Connector; Message=OpsMgr has received new configura&#8230;     <br />4644 7026&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=7026; Source=HealthService; Message=The Health Service successfully logge&#8230;     <br />1548 7023&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=7023; Source=HealthService; Message=The Health Service has downloaded sec&#8230;     <br />1548 7025&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=7025; Source=HealthService; Message=The Health Service has authorized all&#8230;     <br />1548 7024&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=7024; Source=HealthService; Message=The Health Service successfully logge&#8230;     <br />1548 7028&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=7028; Source=HealthService; Message=All RunAs accounts for management gro&#8230;     <br />&#160;&#160; 16 20021&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=20021; Source=OpsMgr Connector; Message=The health service {7B0E947B-2055&#8230;     <br />&#160;&#160; 13 7019&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=7019; Source=HealthService; Message=The Health Service has validated all &#8230;     <br />&#160;&#160;&#160; 4 4002&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=4002; Source=Health Service Script; Message=Microsoft.Windows.Server.Logi&#8230; </p>
<p>&#160;</p>
<p>And “Warning” events (Entrytype –eq 2):</p>
<p><strong>PS&#160; &gt;&gt; $evt | where {$_.Entrytype -eq 2} | select EventID,Source,Message | group eventid </strong></p>
<p>Count Name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Group    <br />&#8212;&#8211; &#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8211;     <br />1511 1103&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=1103; Source=HealthService; Message=Summary: 1 rule(s)/monitor(s) failed &#8230;     <br />&#160; 501 20058&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=20058; Source=OpsMgr Connector; Message=The Root Connector has received b&#8230;     <br />&#160;&#160;&#160; 5 29202&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=29202; Source=OpsMgr Config Service; Message=OpsMgr Config Service could &#8230;     <br />&#160; 421 31501&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=31501; Source=Health Service Modules; Message=No primary recipients were &#8230;     <br />&#160;&#160; 18 10103&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=10103; Source=Health Service Modules; Message=In PerfDataSource, could no&#8230;     <br />&#160;&#160;&#160; 1 29105&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {@{EventID=29105; Source=OpsMgr Config Service; Message=The request for management p&#8230; </p>
<p>&#160;</p>
<p>&#160;</p>
<p>Ok now let’s see those event 20022, for example… so we get an idea of which healthservices they are referring to (20022 indicates&quot; “hearthbeat failure”, btw):</p>
<p><strong>PS&#160; &gt;&gt; $evt | where {$_.eventid -eq 20022} | select message </strong></p>
<p>Message    <br />&#8212;&#8212;-     <br />The health service {7B0E947B-2055-C12A-B6DB-DD6B311ADF39} running on host webapp3.domain1.mydomain.com and s&#8230;     <br />The health service {E3B3CCAA-E797-4F08-860F-47558B3DA477} running on host SERVER1.domain2.mydomain.com and serving&#8230;     <br />The health service {E3B3CCAA-E797-4F08-860F-47558B3DA477} running on host SERVER1.domain2.mydomain.com and serving&#8230;     <br />The health service {E3B3CCAA-E797-4F08-860F-47558B3DA477} running on host SERVER1.domain2.mydomain.com and serving&#8230;     <br />The health service {52E16F9C-EB1A-9FAF-5B9C-1AA9C8BC28E3} running on host DC4WK3.domain1.mydomain.com and se&#8230;     <br />The health service {F96CC9E6-2EC4-7E63-EE5A-FF9286031C50} running on host VWEBDL2.domain1.mydomain.com and s&#8230;     <br />The health service {71987EE0-909A-8465-C32D-05F315C301CC} running on host VDEVWEBPROBE2.domain2.mydomain.com&#8230;.     <br />The health service {BAF6716E-54A7-DF68-ABCB-B1101EDB2506} running on host XP2SMS002.domain2.mydomain.com and serving mana&#8230;     <br />The health service {30C81387-D5E0-32D6-C3A3-C649F1CF66F1} running on host stgweb3.domain3.mydomain.com and&#8230;     <br />The health service {3DCDD330-BBBB-B8E8-4FED-EF163B27DE0A} running on host VWEBDL1.domain1.mydomain.com and s&#8230;     <br />The health service {13A47552-2693-E774-4F87-87DF68B2F0C0} running on host DC2.domain4.mydomain.com and &#8230;     <br />The health service {920BF9A8-C315-3064-A5AA-A92AA270529C} running on host FSCLU2 and serving management group Pr&#8230;     <br />The health service {FAA3C2B5-C162-C742-786F-F3F8DC8CAC2F} running on host WEBAPP4.domain1.mydomain.com and s&#8230;     <br />The health service {3DCDD330-BBBB-B8E8-4FED-EF163B27DE0A} running on host WEBDL1.domain1.mydomain.com and s&#8230;     <br />The health service {3DCDD330-BBBB-B8E8-4FED-EF163B27DE0A} running on host WEBDL1.domain1.mydomain.com and s&#8230; </p>
<p>&#160;</p>
<p>or let’s look at some warning for the Config Service:</p>
<p><strong>PS&#160; &gt;&gt; $evt | where {$_.Eventid -eq 29202} </strong></p>
<p>&#160;&#160; Index Time&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; EntryType&#160;&#160; Source&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; InstanceID Message    <br />&#160;&#160; &#8212;&#8211; &#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8212;&#8212;&#160;&#160; &#8212;&#8212;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8212;&#8212;- &#8212;&#8212;-     <br />5535065 Dec 07 21:18&#160; Warning&#160;&#160;&#160;&#160; OpsMgr Config Ser&#8230;&#160;&#160; 2147512850 OpsMgr Config Service could not retrieve a cons&#8230;     <br />5543960 Dec 09 16:39&#160; Warning&#160;&#160;&#160;&#160; OpsMgr Config Ser&#8230;&#160;&#160; 2147512850 OpsMgr Config Service could not retrieve a cons&#8230;     <br />5545536 Dec 10 01:06&#160; Warning&#160;&#160;&#160;&#160; OpsMgr Config Ser&#8230;&#160;&#160; 2147512850 OpsMgr Config Service could not retrieve a cons&#8230;     <br />5553119 Dec 11 08:24&#160; Warning&#160;&#160;&#160;&#160; OpsMgr Config Ser&#8230;&#160;&#160; 2147512850 OpsMgr Config Service could not retrieve a cons&#8230;     <br />5555677 Dec 11 10:34&#160; Warning&#160;&#160;&#160;&#160; OpsMgr Config Ser&#8230;&#160;&#160; 2147512850 OpsMgr Config Service could not retrieve a cons&#8230; </p>
<p>Once seen those, can you remember of any particular load you had on those days that justifies the instance space changing so quickly that the Config Service couldn’t keep up?</p>
<p>&#160;</p>
<p>Or let’s group those events with ID 21025 by hour, so we know how many Config recalculations we’ve had (which, if many, might indicate <a href="http://blogs.technet.com/kevinholman/archive/2009/10/05/what-is-config-churn.aspx">Config Churn</a>):</p>
<p><strong>PS&#160; &gt;&gt; $evt | where {$_.Eventid -eq 21025} | select TimeGenerated | % {$_.TimeGenerated.ToShortDateString()} | group </strong></p>
<p>Count Name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Group    <br />&#8212;&#8211; &#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8211;     <br />&#160;&#160; 39 12/7/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/7/2009, 12/7/2009, 12/7/2009, 12/7/2009&#8230;}     <br />&#160; 203 12/8/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/8/2009, 12/8/2009, 12/8/2009, 12/8/2009&#8230;}     <br />&#160; 217 12/9/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/9/2009, 12/9/2009, 12/9/2009, 12/9/2009&#8230;}     <br />&#160; 278 12/10/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/10/2009, 12/10/2009, 12/10/2009, 12/10/2009&#8230;}     <br />&#160; 259 12/11/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/11/2009, 12/11/2009, 12/11/2009, 12/11/2009&#8230;}     <br />&#160; 224 12/12/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/12/2009, 12/12/2009, 12/12/2009, 12/12/2009&#8230;}     <br />&#160; 237 12/13/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/13/2009, 12/13/2009, 12/13/2009, 12/13/2009&#8230;}     <br />&#160;&#160; 91 12/14/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/14/2009, 12/14/2009, 12/14/2009, 12/14/2009&#8230;} </p>
<p>&#160;</p>
<p>Event ID 21025 shows that there is a new configuration for the Management Group.</p>
<p>Event ID 29103 has a similar wording, but shows that there is a new configuration for a given Healthservice. These should normally be many more events, unless your only health Service is the RMS, which is unlikely…</p>
<p>If we look at the event description (“message”) in search for the name (or even the GUID, as both are present) or our RMS, as follows, then they should be the same numbers of the 21025 above:</p>
<p><strong>PS&#160; &gt;&gt; $evt | where {$_.Eventid -eq 29103} | where {$_.message -match &quot;myrms.domain.com&quot;} | select TimeGenerated | % {$_.TimeGenerated.ToShortDateString()} | group </strong></p>
<p>Count Name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Group    <br />&#8212;&#8211; &#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8211;     <br />&#160;&#160; 39 12/7/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/7/2009, 12/7/2009, 12/7/2009, 12/7/2009&#8230;}     <br />&#160; 203 12/8/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/8/2009, 12/8/2009, 12/8/2009, 12/8/2009&#8230;}     <br />&#160; 217 12/9/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/9/2009, 12/9/2009, 12/9/2009, 12/9/2009&#8230;}     <br />&#160; 278 12/10/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/10/2009, 12/10/2009, 12/10/2009, 12/10/2009&#8230;}     <br />&#160; 259 12/11/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/11/2009, 12/11/2009, 12/11/2009, 12/11/2009&#8230;}     <br />&#160; 224 12/12/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/12/2009, 12/12/2009, 12/12/2009, 12/12/2009&#8230;}     <br />&#160; 237 12/13/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/13/2009, 12/13/2009, 12/13/2009, 12/13/2009&#8230;}     <br />&#160;&#160; 91 12/14/2009&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {12/14/2009, 12/14/2009, 12/14/2009, 12/14/2009&#8230;} </p>
<p>&#160;</p>
<p>Going back to the initial counts of events by their IDs, when showing the errors the counts above had spotted the presence of a lonely 4512 event, which might have gone undetected if just browsing the eventlog with the GUI, since it only occurred once.</p>
<p>Let’s take a look at it:</p>
<p><strong>PS&#160; &gt;&gt; $evt | where {$_.eventid -eq 4512} </strong></p>
<p>&#160;&#160; Index Time&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; EntryType&#160;&#160; Source&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; InstanceID Message    <br />&#160;&#160; &#8212;&#8211; &#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8212;&#8212;&#160;&#160; &#8212;&#8212;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8212;&#8212;- &#8212;&#8212;-     <br />5560756 Dec 12 11:18&#160; Error&#160;&#160;&#160;&#160;&#160;&#160; HealthService&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 3221229984 Converting data batch to XML failed with error &#8230; </p>
<p>Now, when it is about counts, Powershell is great.&#160; But sometimes Powershell makes it difficult to actually READ the (long) event messages (descriptions) in the console. For example, our event ID 4512 is difficult to read in its entirety and gets truncated with trailing dots…</p>
<p>we can of course increase the window size and/or selecting only THAT one field to read it better:</p>
<p><strong>PS&#160; &gt;&gt; $evt | where {$_.eventid -eq 4512} | select message </strong></p>
<p>Message    <br />&#8212;&#8212;-     <br />Converting data batch to XML failed with error &quot;Not enough storage is available to complete this operation.&quot; (0x8007000E) in rule &quot;Microsoft.SystemCenter.ConfigurationService.CollectionRule.Event.ConfigurationChanged&quot; running for instance &quot;RMS.MYDOMAIN.COM&quot; with id:&quot;{04F4ADED-2C7F-92EF-D620-9AF9685F736F}&quot; in management group &quot;SCOMPROD&quot; </p>
<p>Or, worst case, if it still does not fit, we can still go and search for it in the actual, usual eventlog application… but at least we will have spotted it!</p>
<p>&#160;</p>
<p>The above wants to give you an idea of what is easily accomplished with some simple one-liners, and how it can be a useful aid in analyzing/digging into Eventlogs.</p>
<p>All of the above is ALSO be possible with Logparser, and it would actually be even less heavy on memory usage and it will be quicker, to be honest! </p>
<p>I just like Powershell syntax a lot more, and its ubiquity, which makes it a better option for me. Your mileage may vary, of course.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2009/12/16/opsmgr-eventlog-analysis-with-powershell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PS&gt; Get-Milk</title>
		<link>http://www.muscetta.com/2009/09/17/ps-get-milk/</link>
		<comments>http://www.muscetta.com/2009/09/17/ps-get-milk/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 13:00:08 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Photos]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[baby]]></category>
		<category><![CDATA[cmdlet]]></category>
		<category><![CDATA[daughter]]></category>
		<category><![CDATA[Get-Milk]]></category>
		<category><![CDATA[red]]></category>
		<category><![CDATA[sara]]></category>
		<category><![CDATA[TShirt]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/?p=483</guid>
		<description><![CDATA[I printed a tshirt for Sara with a baby-friendly Powershell cmdlet (&#034;Get-Milk&#034;). She already seems to be wondering what script she can write with it.<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p><a title="Get-Milk" href="http://www.flickr.com/photos/dani3l3/3924854309/"><img src="http://farm3.static.flickr.com/2659/3924854309_7c1f7952c0.jpg" alt="PS&gt; Get-Milk" /></a></p>
<p>I printed a tshirt for Sara with a baby-friendly Powershell cmdlet (&#034;Get-Milk&#034;).<br />
She already seems to be wondering what script she can write with it.</p>
<p><a href="http://www.flickr.com/photos/dani3l3/3924854309/"><img src="http://farm4.static.flickr.com/3536/3924858247_a2da4f9fb9.jpg" alt="PS&gt; Get-Milk" width="500" height="333" /></a></p>
<p><a href="http://www.flickr.com/photos/dani3l3/3924854309/"><img src="http://farm4.static.flickr.com/3449/3925641880_aab0165f75.jpg" alt="PS&gt; Get-Milk" width="500" height="333" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2009/09/17/ps-get-milk/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The mystery of the lost registry values</title>
		<link>http://www.muscetta.com/2009/09/10/mistery-of-lost-registry-values/</link>
		<comments>http://www.muscetta.com/2009/09/10/mistery-of-lost-registry-values/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 14:53:44 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[OpsMgr2007]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[System Center Operations Manager 2007]]></category>
		<category><![CDATA[32bit]]></category>
		<category><![CDATA[64bit]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[Monad]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[StdRegProvider]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[Wbem]]></category>
		<category><![CDATA[WMI]]></category>
		<category><![CDATA[Wow]]></category>
		<category><![CDATA[Wow32]]></category>
		<category><![CDATA[Wow64]]></category>
		<category><![CDATA[Wow6432Node]]></category>
		<category><![CDATA[wrapper]]></category>
		<category><![CDATA[x64]]></category>
		<category><![CDATA[x86]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/?p=481</guid>
		<description><![CDATA[During the OpsMgr Health Check engagement we use custom code to assess the customer’s Management group, as I wrote here already. Given that the customer tells us which machine is the RMS, one of the very first things that we do in our tool is to connect to the RMS’s registry, and check the values [...]<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p>During the OpsMgr Health Check engagement we use custom code to assess the customer’s Management group, <a href="http://www.muscetta.com/2008/12/30/early-adoptions-health-checks-and-new-year-rants/">as I wrote here already</a>. Given that the customer tells us which machine is the RMS, one of the very first things that we do in our tool is to connect to the RMS’s registry, and check the values under <strong>HKLM\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup </strong>to see which machine holds the database. It is a rather critical piece of information for us, as we run a number of queries afterward… so we need to know where the db is, obviously <img src='http://www.muscetta.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I learned from here <a title="http://mybsinfo.blogspot.com/2007/01/powershell-remote-registry-and-you-part.html" href="http://mybsinfo.blogspot.com/2007/01/powershell-remote-registry-and-you-part.html">http://mybsinfo.blogspot.com/2007/01/powershell-remote-registry-and-you-part.html</a> how to access registry remotely thru powershell, by using .Net classes. This is also one of the methods illustrated in this other article on Technet Script Center <a href="http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan09/hey0105.mspx">http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan09/hey0105.mspx</a> </p>
<p>Therefore the “core” instructions of the function I was using to access the registry looked like the following</p>
<p><!-- Code --></p>
<div class="dp-highlighter">
<ol class="dp-rb">
<li class="alt"><span><span>Function GetValueFromRegistry ([string]</span><span class="variable">$computername</span><span>, </span><span class="variable">$regkey</span><span>, </span><span class="variable">$value</span><span>)    </span></span></li>
<li><span>{   </span></li>
<li><span>     </span><span class="variable">$reg</span><span> = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(</span><span class="string">&#039;LocalMachine&#039;</span><span>, </span><span class="variable">$computername</span><span>)   </span></li>
<li><span>     </span><span class="variable">$regKey</span><span>= </span><span class="variable">$reg</span><span>.OpenSubKey(</span><span class="string">&#034;$regKey&#034;</span><span>)   </span></li>
<li><span>     </span><span class="variable">$result</span><span> = </span><span class="variable">$regkey</span><span>.GetValue(</span><span class="string">&#034;$value&#034;</span><span>)   </span></li>
<li><span>     </span><span class="keyword">return</span><span> </span><span class="variable">$result</span><span>  </span></li>
<li><span>}   </span></li>
</ol>
</div>
<p><span> </span></p>
<p>[Note: the actual function is bigger, and contains error handling, and logging, and a number of other things that are unnecessary here]</p>
<p>Therefore, the function was called as follows:<br />
<strong>GetValueFromRegistry $RMS &#034;SOFTWARE\\Microsoft\\Microsoft Operations Manager\\3.0\\Setup&#034; &#034;DatabaseServerName&#034;</strong><br />
Now so far so good.</p>
<p>In theory.</p>
<p> </p>
<p>Now for some reason that I could not immediately explain, we had noticed that this piece of code performing registry accessm while working most of the times, only on SOME occasions was giving errors about not being able to open the registry value…</p>
<p><a href="http://www.muscetta.com/wp-content/uploads/image45.png" rel="lightbox[481]"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.muscetta.com/wp-content/uploads/image_thumb.png" border="0" alt="image" width="518" height="69" /></a></p>
<p>When you are onsite with a customer conducting an assessment, the PFE engineer does not always has the time to troubleshoot the error… as time is critical, we have usually resorted to just running the assessment from ANOTHER machine, and this “solved” the issue… but always left me wondering WHY this was giving an error. I had suspected an issue with permissions first, but it could not be as the permissions were obviously right: performing the assessment from another machine but with the same user was working!</p>
<p>A few days ago <a href="http://blogs.technet.com/stefan_stranger/">my colleague and buddy Stefan Stranger</a> figured out that this was related to the platform architecture:</p>
<ul>
<li>X64 client to x64 RMS was working</li>
<li>X64 client to x86 RMS was working</li>
<li>X86 client to x86 RMS was working</li>
<li><strong>X86 client to x64 RMS was NOT working</strong></li>
</ul>
<p>You don’t need to use our custom code to reproduce this, REGEDIT shows the behavior as well.</p>
<p>If, from a 64-bit server, you open a remote registry connection to 64-bit RMS server, you can see all OpsMgr registry keys:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" src="http://www.muscetta.com/wp-content/uploads/clip_image002.jpg" border="0" alt="clip_image002" width="918" height="268" /></p>
<p>If, anyhow, from a 32-bit server, you open a remote registry connection to 64-bit RMS server, you don’t see ALL – but only SOME &#8211; OpsMgr registry keys:<br />
<img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image004" src="http://www.muscetta.com/wp-content/uploads/clip_image004.jpg" border="0" alt="clip_image004" width="863" height="192" /></p>
<p>So here’s the reason! This is what was happening! How could I not think of this before? It was nothing related to permissions, but to <a href="http://msdn.microsoft.com/en-us/library/aa384232(VS.85).aspx">registry redirection</a>! The issue was happening because the 32 bit machine is using the 32bit registry editor and what it will do when accessing a 64bit machine will be to default to the Wow6432Node location in the registry. There all OpsMgr data won’t be in the WOW64 location on a 64bit machine, only some.</p>
<p>So, just like regedit, the 32bit powershell and the 32bit .Net framework were being redirected to the 32bit-compatibility registry keys… not finding the stuff we needed, whereas a 64bit application could find that. Any 32bit application by default gets redirected to a 32bit-safe registry.</p>
<p>So, after finally UNDERSTANDING what the issue was, I started wondering: ok&#8230; but<strong> how can I access the REAL “HLKM\SOFTWARE\Microsoft” key on a 64bit machine when running this FROM a 32bit machine – WITHOUT being redirected to “HKLM\SOFTWARE\Wow6432Node\Microsoft” ? </strong>What if my application CAN deal just fine with those values and actually NEEDs to access them?</p>
<p>The answer wasn’t as easy as the question. I did a bit of digging on this, and still I have NOT yet found a way to do this with the .Net classes. It seems that in a lot of situations, Powershell or even .Net classes are nice and sweet wrappers on the underlying Windows APIs… but for how sweet and easy they are, they are very often not very complete wrappers – letting you do just about enough for most situations, but not quite everything you would or could with the APi underneath. But I digress, here&#8230;</p>
<p>The good news is that I did manage to get this working, but I had to resort to using dear old WMI StdRegProvider… There are a number of locations on the Internet mentioning the issue of accessing 32bit registry from 64bit machines or vice versa, but all examples I have found were using VBScript. But I needed it in Powershell. Therefore I started with the <a href="http://msdn.microsoft.com/en-us/library/aa393067(VS.85).aspx">VBScript example code that is present here</a>, and I ported it to Powershell.</p>
<p>Handling the WMI COM object from Powershell was slightly less intuitive than in VBScript, and it took me a couple of hours to figure out how to change some stuff, especially this bit that sets the parameters collection:</p>
<blockquote><p>Set Inparams = objStdRegProv.Methods_(&#034;GetStringValue&#034;).Inparameters</p>
<p>Inparams.Hdefkey = HKLM</p>
<p>Inparams.Ssubkeyname = RegKey</p>
<p>Inparams.Svaluename = RegValue</p>
<p>Set Outparams = objStdRegProv.ExecMethod_(&#034;GetStringValue&#034;, Inparams,,objCtx)</p></blockquote>
<p>INTO this:</p>
<blockquote><p>$Inparams = ($objStdRegProv.Methods_ | where {$_.name -eq &#034;GetStringValue&#034;}).InParameters.SpawnInstance_()</p>
<p>($Inparams.Properties_ | where {$_.name -eq &#034;Hdefkey&#034;}).Value = $HKLM</p>
<p>($Inparams.Properties_ | where {$_.name -eq &#034;Ssubkeyname&#034;}).Value = $regkey</p>
<p>($Inparams.Properties_ | where {$_.name -eq &#034;Svaluename&#034;}).Value = $value</p>
<p>$Outparams = $objStdRegProv.ExecMethod_(&#034;GetStringValue&#034;, $Inparams, &#034;&#034;, $objNamedValueSet)</p></blockquote>
<p> </p>
<p>I have only done limited testing at this point and, even if the actual work now requires nearly <strong>15</strong> lines of code to be performed vs. the previous <strong>3 </strong>lines in the .Net implementation, it at least seems to work just fine.</p>
<p>What follows is the complete code of my replacement function, in all its <span style="text-decoration: line-through;">uglyness</span> glory:</p>
<p> </p>
<p><!-- Code --></p>
<div class="dp-highlighter">
<ol class="dp-rb">
<li class="alt"><span>Function GetValueFromRegistryThruWMI([string]</span><span class="variable">$computername</span><span>, </span><span class="variable">$regkey</span><span>, </span><span class="variable">$value</span><span>)   </span></li>
<li><span>{   </span></li>
<li><span>    </span><span class="comment">#constant for the HLKM </span><span>  </span></li>
<li><span>    </span><span class="variable">$HKLM</span><span> = </span><span class="string">&#034;&amp;h80000002&#034;</span><span>  </span></li>
<li><span> </span></li>
<li><span>    #creates an SwbemNamedValueSet object</span></li>
<li><span>    </span><span class="variable">$objNamedValueSet</span><span> = </span><span class="builtin">New-Object</span><span> -COM </span><span class="string">&#034;WbemScripting.SWbemNamedValueSet&#034;</span><span>  </span></li>
<li><span> </span></li>
<li><span>    #adds the actual value that will requests the target to provide 64bit-registry info</span></li>
<li><span>    </span><span class="variable">$objNamedValueSet</span><span>.Add(</span><span class="string">&#034;__ProviderArchitecture&#034;</span><span>, 64) | </span><span class="builtin">Out-Null</span><span>  </span></li>
<li> </li>
<li><span>    #back to all the other usual COM objects for WMI that you have used a zillion times in VBScript</span></li>
<li><span>    </span><span class="variable">$objLocator</span><span> = </span><span class="builtin">New-Object</span><span> -COM </span><span class="string">&#034;Wbemscripting.SWbemLocator&#034;</span><span>  </span></li>
<li><span>    </span><span class="variable">$objServices</span><span> = </span><span class="variable">$objLocator</span><span>.ConnectServer(</span><span class="variable">$computername</span><span>,</span><span class="string">&#034;root\default&#034;</span><span>,</span><span class="string">&#034;&#034;</span><span>,</span><span class="string">&#034;&#034;</span><span>,</span><span class="string">&#034;&#034;</span><span>,</span><span class="string">&#034;&#034;</span><span>,</span><span class="string">&#034;&#034;</span><span>,</span><span class="variable">$objNamedValueSet</span><span>)   </span></li>
<li><span>    </span><span class="variable">$objStdRegProv</span><span> = </span><span class="variable">$objServices</span><span>.Get(</span><span class="string">&#034;StdRegProv&#034;</span><span>)   </span></li>
<li><span>  </span></li>
<li class="alt"><span>    </span><span class="comment"># Obtain an InParameters object specific to the method. </span><span>  </span></li>
<li><span>    </span><span class="variable">$Inparams</span><span> = (</span><span class="variable">$objStdRegProv</span><span>.Methods_ | </span><span class="keyword">where</span><span> {</span><span class="variable">$_</span><span>.name -eq </span><span class="string">&#034;GetStringValue&#034;</span><span>}).InParameters.SpawnInstance_()   </span></li>
<li><span>  </span></li>
<li class="alt"><span>    </span><span class="comment"># Add the input parameters </span><span>  </span></li>
<li><span>    (</span><span class="variable">$Inparams</span><span>.Properties_ | </span><span class="keyword">where</span><span> {</span><span class="variable">$_</span><span>.name -eq </span><span class="string">&#034;Hdefkey&#034;</span><span>}).Value = </span><span class="variable">$HKLM</span><span>  </span></li>
<li><span>    (</span><span class="variable">$Inparams</span><span>.Properties_ | </span><span class="keyword">where</span><span> {</span><span class="variable">$_</span><span>.name -eq </span><span class="string">&#034;Ssubkeyname&#034;</span><span>}).Value = </span><span class="variable">$regkey</span><span>  </span></li>
<li><span>    (</span><span class="variable">$Inparams</span><span>.Properties_ | </span><span class="keyword">where</span><span> {</span><span class="variable">$_</span><span>.name -eq </span><span class="string">&#034;Svaluename&#034;</span><span>}).Value = </span><span class="variable">$value</span><span>  </span></li>
<li><span>  </span></li>
<li class="alt"><span>    </span><span class="comment">#Execute the method </span><span>  </span></li>
<li><span>    </span><span class="variable">$Outparams</span><span> = </span><span class="variable">$objStdRegProv</span><span>.ExecMethod_(</span><span class="string">&#034;GetStringValue&#034;</span><span>, </span><span class="variable">$Inparams</span><span>, </span><span class="string">&#034;&#034;</span><span>, </span><span class="variable">$objNamedValueSet</span><span>)   </span></li>
<li><span>  </span></li>
<li class="alt"><span>    </span><span class="comment">#shows the return value </span><span>  </span></li>
<li><span>    (</span><span class="variable">$Outparams</span><span>.Properties_ | </span><span class="keyword">where</span><span> {</span><span class="variable">$_</span><span>.name -eq </span><span class="string">&#034;ReturnValue&#034;</span><span>}).Value   </span></li>
<li><span>  </span></li>
<li class="alt"><span>    </span><span class="keyword">if</span><span> ((</span><span class="variable">$Outparams</span><span>.Properties_ | </span><span class="keyword">where</span><span> {</span><span class="variable">$_</span><span>.name -eq </span><span class="string">&#034;ReturnValue&#034;</span><span>}).Value -eq 0)   </span></li>
<li><span>    {   </span></li>
<li><span>       write-host </span><span class="string">&#034;it worked&#034;</span><span>  </span></li>
<li><span>       </span><span class="variable">$result</span><span> = (</span><span class="variable">$Outparams</span><span>.Properties_ | </span><span class="keyword">where</span><span> {</span><span class="variable">$_</span><span>.name -eq </span><span class="string">&#034;sValue&#034;</span><span>}).Value   </span></li>
<li><span>       write-host </span><span class="string">&#034;Result: $result&#034;</span><span>  </span></li>
<li><span>       </span><span class="keyword">return</span><span> </span><span class="variable">$result</span><span>  </span></li>
<li><span>    }   </span></li>
<li><span>    </span><span class="keyword">else</span><span>  </span></li>
<li><span>    {   </span></li>
<li><span>        write-host </span><span class="string">&#034;nope&#034;</span><span>  </span></li>
<li><span>    }   </span></li>
<li><span>}   </span></li>
</ol>
</div>
<p><span> </span></p>
<p><span>which can be called similarly to the previous one: </span><br />
<strong><span>GetValueFromRegistryThruWMI </span><span class="variable">$RMS</span><span> </span><span class="string">&#034;SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup&#034;</span><span> </span><span class="string">&#034;DatabaseServerName&#034;</span></strong></p>
<p>[Note: you don’t need the double\escape backslashes here, compared to the .Net implementation]</p>
<p>Enjoy your cross-architecture registry access: from 32bit to 64bit &#8211; and back!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2009/09/10/mistery-of-lost-registry-values/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the SCX Agent with WSMan from Powershell v2</title>
		<link>http://www.muscetta.com/2009/06/01/using-the-scx-agent-with-wsman-from-powershell-v2/</link>
		<comments>http://www.muscetta.com/2009/06/01/using-the-scx-agent-with-wsman-from-powershell-v2/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 17:47:08 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Cross Platform]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MOM]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[OpsMgr2007]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[System Center Operations Manager 2007]]></category>
		<category><![CDATA[xplat]]></category>
		<category><![CDATA[Get-WSManInstance]]></category>
		<category><![CDATA[Interop]]></category>
		<category><![CDATA[scx]]></category>
		<category><![CDATA[Test-WSMan]]></category>
		<category><![CDATA[ws-man]]></category>
		<category><![CDATA[wsman]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/?p=473</guid>
		<description><![CDATA[So Powershell v2 adds a nice bunch of Ws-Man related cmdlets. Let’s see how we can use them to interact with OpenPegasus’s WSMan on a SCX Agent. PS C:\maint&#62; test-wsman -computer virtubuntu.huis.dom -port 1270 -authentication basic -credential (get-credential) -usessl cmdlet Get-Credential at command pipeline position 1 Supply values for the following parameters: Credential But we [...]<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p>So Powershell v2 adds <a href="http://blogs.msdn.com/wmi/archive/2009/03/26/wsman-enhancements-in-powershell-2-0.aspx" target="_blank">a nice bunch of Ws-Man related cmdlets</a>. Let’s see how we can use them to interact with OpenPegasus’s WSMan on a SCX Agent.</p>
<p>PS C:\maint&gt; <strong>test-wsman -computer virtubuntu.huis.dom -port 1270 -authentication basic -credential (get-credential) -usessl</strong></p>
<p>cmdlet Get-Credential at command pipeline position 1<br />
Supply values for the following parameters:<br />
Credential</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.muscetta.com/wp-content/uploads/image-thumb22.png" border="0" alt="image" width="323" height="252" /></p>
<p>But we do get this error:</p>
<p><span style="color: #ff0000;">Test-WSMan : The server certificate on the destination computer (virtubuntu.huis.dom:1270) has the following errors:<br />
The SSL certificate could not be checked for revocation. The server used to check for revocation might be unreachable.</span></p>
<p><span style="color: #ff0000;">The SSL certificate is signed by an unknown certificate authority.<br />
At line:1 char:11<br />
+ test-wsman &lt;&lt;&lt;&lt;  -computer virtubuntu.huis.dom -port 1270 -authentication basic -credential (get-credential) -usessl<br />
+ CategoryInfo          : InvalidOperation: (:) [Test-WSMan], InvalidOperationException<br />
+ FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.TestWSManCommand</span></p>
<p>The credentials above have to be a unix login. Which we typed correctly. But we still can&#039;t get thru, as the certificate used by the agent is not trusted by our workstation. This seems to be the “usual” issue I first faced when testing SCX with WINRM in beta1. <a href="http://www.muscetta.com/2008/05/04/testing-system-center-cross-plaform-extentions/">At the time I simply dismissed it with the following sentence</a></p>
<blockquote><p>[…] Of course you have to solve some other things such as DNS resolution AND trusting the self-issued certificates that the agent uses, first. Once you have done that, you can run test queries from the Windows box towards the Unix ones by using WinRM. […]</p></blockquote>
<p>and I sincerely thought that it would explain pretty well… but eventually a lot of people got confused by this and did not know what to do, especially for the part that goes about trusting the certificate.  Anyway, <a href="http://www.muscetta.com/2009/03/27/cross-platform-in-opsmgr-2007-r2-release-candidate/">in the following posts I figured out you could pass the –skipCACheck parameter to WINRM</a>… which solved the issue with having to trust the certificate (which is fine for testing, but I would not use that for automations and scripts running in production… as it might expose your credentials to man-in-the-middle attacks).</p>
<p>So it seems that with the Powershell cmdlets we are back to that issue, as I can’t find a parameter to skip the CA check. Maybe it is there, but with PSv2 not having been released yet, I don&#039;t know everything about it, and the CTP documentation is not yet complete. Therefore, back to trusting the certificate.</p>
<p>Trusting the certificate is actually very simple, but it can be a bit tricky when passing those certs back and forth from unix to windows. So let&#039;s make the process a bit clearer.</p>
<p>All of the SCX-agents certificates are ultimately signed by a key on the Management server that has discovered them, but I don&#039;t currently know where that certificate/key is stored on the management server. Anyway, you can get it from the agent certificate &#8211; as you only really need the public key, not the private signing key.</p>
<p>Use WinSCP or any other utility to copy the certificate off one of the agents.<br />
You can find that in the <strong>/etc/opt/microsoft/scx/ssl</strong> location:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.muscetta.com/wp-content/uploads/image-thumb23.png" border="0" alt="image" width="772" height="219" /></p>
<p>that <strong>scx-host-computername.pem</strong> is your agent certificate.</p>
<p>Copy it to the Management server and change its extension from <strong>.pem</strong> to <strong>.cer</strong>. Now Windows will be happy to show it to you with the usual Certificate interface:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.muscetta.com/wp-content/uploads/image-thumb24.png" border="0" alt="image" width="404" height="472" /></p>
<p>We need to go to the “Certification Path” tab, select the ISSUER certificate (the one called “SCX-Certificate”):</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.muscetta.com/wp-content/uploads/image-thumb25.png" border="0" alt="image" width="813" height="476" /></p>
<p>then go to the “Details” tab, and use the “Copy to File” button to export the certificate.</p>
<p>After you have the certificate in a .CER file, you can add it to the “trusted root certification authorities” store on the computer you are running your powershell tests from.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.muscetta.com/wp-content/uploads/image-thumb26.png" border="0" alt="image" width="792" height="374" /></p>
<p>So after you have trusted it, the same command as above actually works now:</p>
<p>PS C:\maint&gt; <strong>test-wsman -computer virtubuntu.huis.dom -port 1270 -authentication basic -credential (get-credential) -usessl</strong></p>
<p>cmdlet Get-Credential at command pipeline position 1<br />
Supply values for the following parameters:<br />
Credential</p>
<p>wsmid           : http://schemas.dmtf.org/wbem/wsman/identify/1/wsmanidentity.xsd<br />
lang            :<br />
ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd<br />
ProductVendor   : Microsoft System Center Cross Platform<br />
ProductVersion  : 1.0.4-248</p>
<p>Ok, we can talk to it! Now we can do something funnier, like actually returning instances and/or calling methods:</p>
<p>PS C:\maint&gt; <strong>Get-WSManInstance -computer virtubuntu.huis.dom -authentication basic -credential (get-credential) -port 1270 -usessl -enumerate http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem?__cimnamespace=root/scx</strong></p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.muscetta.com/wp-content/uploads/image-thumb27.png" border="0" alt="image" width="836" height="697" /></p>
<p>This is far from exhaustive, but should get you started on a world of possibilities about automating diagnostics and responses with Powershell v2 towards the OpsMgr 2007 R2 Cross-Platform machines. Enjoy!</p>
<p><strong>Disclaimer</strong></p>
<p>The information in this weblog is provided &#034;AS IS&#034; with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my own personal opinion. All code samples are provided &#034;AS IS&#034; without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.<br />
THIS WORK IS NOT ENDORSED AND NOT EVEN CHECKED, AUTHORIZED, SCRUTINIZED NOR APPROVED BY MY EMPLOYER, AND IT ONLY REPRESENT SOMETHING WHICH I&#039;VE DONE IN MY FREE TIME. NO GUARANTEE WHATSOEVER IS GIVEN ON THIS. THE AUTHOR SHALL NOT BE MADE RESPONSIBLE FOR ANY DAMAGE YOU MIGHT INCUR WHEN USING THIS INFORMATION. The solution presented here IS NOT SUPPORTED by Microsoft.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2009/06/01/using-the-scx-agent-with-wsman-from-powershell-v2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Get-WmiCustom (aka: Get-WMIObject with timeout!)</title>
		<link>http://www.muscetta.com/2009/05/27/get-wmicustom/</link>
		<comments>http://www.muscetta.com/2009/05/27/get-wmicustom/#comments</comments>
		<pubDate>Wed, 27 May 2009 18:23:07 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[timeout]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/?p=443</guid>
		<description><![CDATA[I make heavy use of WMI. But when using it to gather information from customer’s machines for assessments, I sometimes find the occasional broken WMI repository. There are a number of ways in which WMI can become corrupted and return weird results. Most of the times you would just get errors, such as “Class not [...]<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p>I make heavy use of WMI.</p>
<p>But when using it to gather information from customer’s machines for assessments, I sometimes find the occasional broken WMI repository. There are a number of ways in which WMI can become corrupted and return weird results. Most of the times you would just get errors, such as “Class not registered” or “provider load failure”. I can handle those errors from within scripts.</p>
<p>But there are some, more subtle &#8211; and annoying – ways in which the WMI repository can get corrupted. the situations I am talking about are the ones when WMI will accept your query… will say it is executing it… but it will never actually return any error, and just stay stuck performing your query forever. Until your client application decides to time out. Which in some cases does not happen.</p>
<p>Now that was my issue – when my assessment script (which was using the handy Powershell <a href="http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/get-wmiobject.mspx">Get-WmiObject cmdlet</a>) would hit one of those machines… the whole script would hang forever and never finish its job. Ok, sure, the solution to this would be actually FIXING the WMI repository and then try again. But remember I am talking of an assessment: if the information I am getting is just one piece of a bigger puzzle, and I don’t necessarily care about it and can continue without that information – I want to be able to do it, to skip that info, maybe the whole section, report an error saying I am not able to get that information, and continue to get the remaining info. I can still fix the issue on the machine afterward AND then run the assessment script again, but in the first place I just want to get a picture of how the system looks like. With the good and with the bad things. Especially, I do want to take that whole picture – not just a piece of it.</p>
<p>Unfortunately, the <a href="http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/get-wmiobject.mspx">Get-WmiObject cmdlet</a> does not let you specify a timeout. Therefore I cooked my own function which has a compatible behaviour to that of Get-WmiObject, but with an added “-timeout” parameter which can be set. I dubbed it “Get-WmiCustom”</p>
<p><strong>Function Get-WmiCustom([string]$computername,[string]$namespace,[string]$class,[int]$timeout=15)<br />
{<br />
$ConnectionOptions = new-object System.Management.ConnectionOptions<br />
$EnumerationOptions = new-object System.Management.EnumerationOptions </strong></p>
<p><strong> $timeoutseconds = new-timespan -seconds $timeout<br />
$EnumerationOptions.set_timeout($timeoutseconds) </strong></p>
<p><strong> $assembledpath = &#034;\\&#034; + $computername + &#034;\&#034; + $namespace<br />
#write-host $assembledpath -foregroundcolor yellow </strong></p>
<p><strong> $Scope = new-object System.Management.ManagementScope $assembledpath, $ConnectionOptions<br />
$Scope.Connect() </strong></p>
<p><strong> $querystring = &#034;SELECT * FROM &#034; + $class<br />
#write-host $querystring </strong></p>
<p><strong> $query = new-object System.Management.ObjectQuery $querystring<br />
$searcher = new-object System.Management.ManagementObjectSearcher<br />
$searcher.set_options($EnumerationOptions)<br />
$searcher.Query = $querystring<br />
$searcher.Scope = $Scope </strong></p>
<p><strong> trap { $_ } $result = $searcher.get() </strong></p>
<p><strong> return $result<br />
}</strong></p>
<p>You can call it as follows, which is similar to how you would call get-WmiObject</p>
<p><strong>get-wmicustom -class Win32_Service -namespace &#034;root\cimv2&#034; -computername server1.domain.dom</strong></p>
<p>or, of course, specifying the timeout (in seconds):</p>
<p><strong>get-wmicustom -class Win32_Service -namespace &#034;root\cimv2&#034; -computername server1.domain.dom –timeout 1</strong></p>
<p>and obviously, since the function returns objects just like the original cmdlet, it is also possible to pipe them to other commands:</p>
<p><strong>get-wmicustom -class Win32_Service -namespace &#034;root\cimv2&#034; -computername server1.domain.dom –timeout 1 | Format-Table</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2009/05/27/get-wmicustom/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Early Adoptions, Health Checks and New Year Rants.</title>
		<link>http://www.muscetta.com/2008/12/30/early-adoptions-health-checks-and-new-year-rants/</link>
		<comments>http://www.muscetta.com/2008/12/30/early-adoptions-health-checks-and-new-year-rants/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 15:10:26 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[MOM]]></category>
		<category><![CDATA[MOM2005]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[OpsMgr2007]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Photos]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[System Center Operations Manager 2007]]></category>
		<category><![CDATA[HC]]></category>
		<category><![CDATA[Health Check]]></category>
		<category><![CDATA[HealthCheck]]></category>
		<category><![CDATA[Premier]]></category>
		<category><![CDATA[Premier Field Engineer]]></category>
		<category><![CDATA[RAP]]></category>
		<category><![CDATA[Risk Assessment Program]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[Support]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/?p=390</guid>
		<description><![CDATA[Two days ago I read the following Tweet by Hugh MacLeod: &#034;[...] Early Adopter Problem: How to differentiate from the bandwagon, once the bandwagon starts moving faster than you are [...]&#034; That makes me think of early adoption of a few technologies I have been working with, and how the community around those evolved. For [...]<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p><a href="http://flickr.com/photos/dani3l3/3150411409/"><img src="http://farm4.static.flickr.com/3258/3150411409_8ce3a8ea75.jpg" alt="Generations" width="500" height="333" /></a></p>
<p>Two days ago I read <a href="http://twitter.com/gapingvoid/status/1082816395">the following Tweet by Hugh MacLeod</a>:</p>
<blockquote><p>&#034;[...] Early Adopter Problem: How to differentiate from the bandwagon, once the bandwagon starts moving faster than you are [...]&#034;</p></blockquote>
<p>That makes me think of early adoption of a few technologies I have been working with, and how the community around those evolved. For example:</p>
<p><strong>Operations Manager</strong>&#8230; early adoption meant that I have been working with it since the beta, had posted <a href="http://www.muscetta.com/2007/05/10/create-a-script-based-unit-monitor-in-opsmgr2007-via-the-gui/">one of the earliest posts about how to use a script in a Unit Monitor back in may 2007</a> (the product was released in April 2007 and there was NO documentation back then, so we had to really try to figure out everything&#8230;), but <a href="http://contoso.se/blog/?p=305">someone seems to think it is worth repeating the very same lesson in November 2008</a>, with not a lot of changes, as <a href="http://twitter.com/dani3l3/status/1030704645">I wrote here</a>. I don&#039;t mean being rude to Anders&#8230; repeating things will surely help the late adopters finding the information they need, of course.</p>
<p>Also, I started playing early with <strong>Powershell</strong>. <a href="http://www.muscetta.com/2006/11/24/out-blog/">I posted my first (and only) cmdlet</a> back in 2006. It was not a lot more than a test for myself to learn how to write one, but that&#039;s just to say that I started playing early with it. I have been using it <a href="http://www.muscetta.com/2007/05/30/death-by-right-click-delete-nope-powershell/">to automate tasks</a> for example.</p>
<p>Going back to the quote above, everyone gets on the bandwagon posting <a href="http://www.systemcenterforum.org/news/advanced-example-using-powershell-and-the-opsmgr-sdk-creating-and-updating-groups/">examples and articles</a>. I had been asked a few times about writing articles on OpsMgr and Powershell usage (for example by <a href="http://www.powershell.it">www.powershell.it</a>) but I declined, as I was too busy using this knowledge to do stuff for work (where “work” is defined as in “work that pays your mortgage”), rather than seeking personal prestige through articles and blogs. Anyway, that kind of articles are appearing now all over the Internet and the blogosphere now. The above examples made me think of early adoption, and the bandwagon that follows later on… but even as an early adopter, I was never very noisy or visible.</p>
<p>Now, going back to what I do for work, (which <a href="http://blogs.msdn.com/dmuscett/archive/2005/09/02/459914.aspx">I mentioned here</a> and <a href="http://www.muscetta.com/2007/12/27/simply-works/">here in the past</a>), I work in the <a href="https://www.microsoft.com/emea/careers/technicalJobs/PremierFieldEngineer.mspx">Premier Field Engineering</a> organization of Microsoft Services, which provides Premier services to customers. <a href="http://www.microsoft.com/services/microsoftservices/srv_premier.mspx">Microsoft Premier customer have a wide range of Premier agreement features and components</a> that they can use to support their people, improve their processes, and improve the productive use of the Microsoft technology they have purchased. Some of these services we provide are known to the world as “<a href="http://www.google.com/search?hl=en&amp;q=health+check+site%3Amicrosoft.com&amp;btnG=Search">Health Checks</a>”, some as “<a href="http://www.google.com/search?hl=en&amp;q=risk+assessment+program+site%3Amicrosoft.com&amp;btnG=Search">Risk Assessment Programs</a>” (or, shortly, RAPs). These are basically services where one of our technology experts goes on the customer site and there he uses a custom, private Microsoft tool to gather a huge amount of data from the product we mean to look at (be it SQL, Exchange, AD or anything else….). The Health Check or RAP tool collects the data and outputs a draft of the report that will be delivered to the customer later on, with all the right sections and chapters. This is done so that every report of the same kind will look consistent, even if the engagement is performed by a different engineer in a different part of the world. The engineer will of course analyze the collected data and write recommendations about what is configured properly and/or about what could or should be changed and/or improved in the implementation to make it adhere to Best Practices. To make sure only the right people actually go onsite to do this job we have a strict internal accreditation process that must be followed; only accredited resources that know the product well enough and know exactly how to interpret the data that the tool collects are allowed to use it and to deliver the engagement, and present/write the findings to the customer.</p>
<p>So why am I telling you this here, and how have I been using my early knowledge of OpsMgr and Powershell for ?</p>
<p>I have used that to write the Operations Manager Health Check, of course!</p>
<p>We had a <a href="http://download.microsoft.com/download/f/9/7/f974f0df-66fd-47e9-a1ac-c6fdbe3c723a/Operations_Manager_Server_Health_Check.pdf">MOM 2005 Health Check </a>already, but since the technology has changed so much, from MOM to OpsMgr, we had to write a completely new tool. Jeff  (the original MOM2005 author, who does not have a blog that I can link to) and me are the main coders of this tool… and the tool itself is A POWERSHELL script. A longish one, of course (7000 lines, more or less), but nothing more than a Powershell script, at the end of the day. There are a few more colleagues that helped shape the features and tested the tool, including <a href="http://blogs.technet.com/kevinholman/">Kevin Holman</a>. Some of the <a href="http://blogs.technet.com/kevinholman/archive/2007/10/18/useful-operations-manager-2007-sql-queries.aspx">database queries on Kevin’s blog</a> are in fact what we use to extract some of the data (beware that some of those queries have recently been updated, in case you saved them and using your local copy!), while some other information are using internal and/or custom queries. Some other times we use OpsMgr cmdlets or go to the SDK service, but a lot of times we query the database directly (we really should use the SDK all the times, but for certain stuff direct database access is way faster). It took most of the past year to write it, test it, troubleshoot it, fix it, and deliver the first engagements as “beta” to some customers to help iron out the process&#8230; and now the delivery is available! If a year seems like a long time, you have to consider this is all work that gets done next to what we all have to normally do with customers, not replacing it (i.e. I am not free to sit on my butt all day and just write the tool&#8230; <a href="http://download.microsoft.com/download/e/9/d/e9df53f8-3069-4fe4-bdbd-0d7abd86488a/PremFieldEnginr_161107b.pdf">I still have to deliver services to customers day in day out, in the meantime</a>).</p>
<p>Occasionally, during this past calendar year, that is approaching its end, I have been willing and have found some extra time to disclose some bits and pieces, techniques and prototypes of how to use Powershell and OpsMgr together, <a href="http://www.muscetta.com/2008/11/29/programmatically-check-for-management-pack-updates-in-opsmgr-2007-r2/">such as innovative ways to use Powershell in OpsMgr against beta features</a>, but in general most of my early adopter’s investment went into the private tool for this engagement, and that is one of the reasons I couldn’t blog or write much about it, being it Microsoft Intellectual Property.</p>
<p>But it is also true that <a href="http://twitter.com/dani3l3/status/997620250">I did not care to write other stuff when I considered it too easy or it could be found in the documentation</a>. I like writing of ideas, thoughts, rants OR things that I discover and that are not well documented at the time I study them… so when I figure out things I might like leaving a trail for some to follow. But I am not here to spoon feed people like some in the bandwagon are doing. Now the bandwagon is busy blogging and writing continuously about some aspect of OpsMgr (known or unknown, documented or not), and the answer to <a href="http://twitter.com/gapingvoid/status/1082816395">the original question of Hugh</a> is, in my opinion, that it does not really matter what the bandwagon is doing right now. I was never here to do the same thing. I think <strong>that</strong> is my differentiator. I am not saying that what a bunch of colleagues and enthusiasts is doing is not useful: blogging and writing about various things they experiment with is interesting and it will be useful to people. But blogs are useful until a certain limit. I think that blogs are best suited for conversations and thoughts (rather than for &#034;howto&#039;s&#034;), and what I would love to see instead is: less marketing hype when new versions are announced and more real, official documentation.</p>
<p>But I think I should stop caring about what the bandwagon is doing, because that&#039;s just another ego trip at the end of the day. What I should more sensibly do, would be listening to <a href="http://freewillastrology.com/horoscopes/pisces.html">my horoscope</a> instead:</p>
<blockquote><p>[…] &#034;How do you slay the dragon?&#034; journalist Bill Moyers asked mythologist Joseph Campbell in an interview. By &#034;dragon,&#034; he was referring to the dangerous beast that symbolizes the most unripe and uncontrollable part of each of our lives. In reply to Moyers, Campbell didn&#039;t suggest that you become a master warrior, nor did he recommend that you cultivate high levels of sleek, savage anger. &#034;Follow your bliss,&#034; he said simply. Personally, I don&#039;t know if that&#039;s enough to slay the dragon &#8212; I&#039;m inclined to believe that you also have to take some defensive measures &#8212; but it&#039;s definitely worth an extended experiment. Would you consider trying that in 2009? […]</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2008/12/30/early-adoptions-health-checks-and-new-year-rants/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programmatically Check for Management Pack updates in OpsMgr 2007 R2</title>
		<link>http://www.muscetta.com/2008/11/29/programmatically-check-for-management-pack-updates-in-opsmgr-2007-r2/</link>
		<comments>http://www.muscetta.com/2008/11/29/programmatically-check-for-management-pack-updates-in-opsmgr-2007-r2/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 22:10:21 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Cross Platform]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[OpsMgr2007]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[System Center Operations Manager 2007]]></category>
		<category><![CDATA[beta]]></category>
		<category><![CDATA[Flickr]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[Interop]]></category>
		<category><![CDATA[R2]]></category>
		<category><![CDATA[scom]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[web service]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/2008/11/29/programmatically-check-for-management-pack-updates-in-opsmgr-2007-r2/</guid>
		<description><![CDATA[One of the cool new features of System Center Operations Manager 2007 R2 is the possibility to check and update Management Packs from the catalog on the Internet directly from the Operators Console: Even if the backend for this feature is not yet documented, I was extremely curious to see how this had actually been [...]<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p>One of the cool new features of <a href="http://technet.microsoft.com/en-us/opsmgr/dd239186.aspx">System Center Operations Manager 2007 R2</a> is the possibility to check and update <a href="http://www.microsoft.com/technet/prodtechnol/scp/opsmgr07.aspx">Management Packs from the catalog on the Internet</a> directly from the Operators Console:</p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://www.muscetta.com/wp-content/uploads/image-thumb12.png" border="0" alt="Select Management Packs from Catalog" width="640" height="406" /></p>
<p>Even if the backend for this feature is not yet documented, I was extremely curious to see how this had actually been implemented. Especially since it took a while to have this feature available for OpsMgr, I had the suspicion that it could not be as simple as one downloadable XML file, like <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=A24CEA3A-1920-4B18-8CF2-8BF78C94C917&amp;displaylang=en">the old MOM2005&#039;s MPNotifier</a> had been using in the past.</p>
<p>Therefore I observed the console&#039;s traffic through the lens of my proxy, and got my answer:</p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://www.muscetta.com/wp-content/uploads/image18.png" border="0" alt="ISA Server Log" width="813" height="58" /></p>
<p>So that was it: a .Net Web Service.</p>
<p>I tried to ask the web service itself for discovery information, but failed:</p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://www.muscetta.com/wp-content/uploads/image19.png" border="0" alt="WSDL" width="653" height="145" /></p>
<p>Since there is no WSDL available, but I badly wanted to interact with it, I had to figure out: what kind of requests would be allowed to it, how should they be written, what methods could they call and what parameters should I pass in the call. In order to get started on this, I thought I could just observe its network traffic. And so I did&#8230; I fired up <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=f4db40af-1e08-4a21-a26b-ec2f4dc4190d&amp;displaylang=en">Network Monitor</a> and captured the traffic:</p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://www.muscetta.com/wp-content/uploads/clip-image0025-thumb.jpg" border="0" alt="Microsoft Network Monitor 3.2" width="640" height="335" /></p>
<p><a href="http://blogs.technet.com/netmon/">Microsoft Network Monitor</a> is beautiful and useful for this kind of stuff, as it lets you easily identify which application a given stream of traffic belongs to, just like in the picture above. After I had isolated just the traffic from the Operations Console, I then saved those captures packets in CAP format and opened it again in <a href="http://www.wireshark.org/">Wireshark</a> for a different kind of analysis &#8211; &#034;Follow TCP Stream&#034;:</p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://www.muscetta.com/wp-content/uploads/clip-image0027-thumb.jpg" border="0" alt="Wireshark: Follow TCP Stream" width="640" height="450" /></p>
<p>This showed me the reassembled conversation, and what kind of request was actually done to the Web Service. That was the information I needed.</p>
<p>Ready to rock at this point, I came up with <a href="http://www.muscetta.org/Check-MPUpdates.zip"><strong>this Powershell script</strong></a> (to be run in OpsMgr Command Shell) that will:</p>
<p>1) connect to the web service and retrieve the complete MP list for R2 (this part is also useful on its own, as it shows how to interact with a SOAP web service in <a href="http://www.microsoft.com/powershell">Powershell</a>, invoking a method of the web service by issuing a specially crafted POST request. To give due credit, for this part I first looked at <a href="http://users.skynet.be/pascalbotte/rcx-ws-doc/perlpost.htm">this PERL code</a>, which I then adapted and ported to Powershell);</p>
<p>2) loop through the results of the &#034;Get-ManagementPack&#034; opsmgr cmdlet and compare each MP found in the Management Group with those pulled from the catalog;</p>
<p>3) display a table of all imported MPs with both the version imported in your Management Group AND the version available on the catalog:</p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://www.muscetta.com/wp-content/uploads/image-thumb13.png" border="0" alt="Script output in OpsMgr Command Shell" width="596" height="480" /></p>
<p>Remember that this is just SAMPLE code, it is not meant to be used in production environment and it is worth mentioning again that OpsMgr2007 R2 this is BETA software at the time of writing, therefore this functionality (and its implementation) might change at any time, and the script will break. Also, at present, the MP Catalog web service still returns slightly older MP versions and it is not yet kept in sync and updated with MP Releases, but it will be ready and with complete/updated content by the time R2 gets released.</p>
<p><strong>Disclaimer</strong></p>
<p>The information in this weblog is provided &#034;AS IS&#034; with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my own personal opinion. All code samples are provided &#034;AS IS&#034; without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.<br />
THIS WORK IS NOT ENDORSED AND NOT EVEN CHECKED, AUTHORIZED, SCRUTINIZED NOR APPROVED BY MY EMPLOYER, AND IT ONLY REPRESENT SOMETHING WHICH I&#039;VE DONE IN MY FREE TIME. NO GUARANTEE WHATSOEVER IS GIVEN ON THIS. THE AUTHOR SHALL NOT BE MADE RESPONSIBLE FOR ANY DAMAGE YOU MIGHT INCUR WHEN USING THIS INFORMATION. The solution presented here IS NOT SUPPORTED by Microsoft.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2008/11/29/programmatically-check-for-management-pack-updates-in-opsmgr-2007-r2/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Conversation about Blogs with a customer</title>
		<link>http://www.muscetta.com/2008/03/28/conversation-about-blogs-with-a-customer/</link>
		<comments>http://www.muscetta.com/2008/03/28/conversation-about-blogs-with-a-customer/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 14:24:17 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[OpsMgr2007]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[Blogs]]></category>
		<category><![CDATA[Choice]]></category>
		<category><![CDATA[Funny]]></category>
		<category><![CDATA[gapingvoid]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/2008/03/28/conversation-about-blogs-with-a-customer/</guid>
		<description><![CDATA[I usually don&#039;t like mentioning specific facts that happened to me at work. But work is part of life, so even if this is mostly a personal blog, I cannot help myself but write about certain things that make me think when they happen. When I end up having conversations such as this, I get [...]<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p>I usually don&#039;t like mentioning specific facts that happened to me at work. But work is part of life, so even if this is mostly a personal blog, I cannot help myself but write about certain things that make me think when they happen.</p>
<p>When I end up having conversations such as this, I get really sad: I thought we had finally passed the arrogant period where we had to spoon-feed customers, and I thought we were now mature enough to consider them smart people and providing <a href="http://www.microsoft.com/powershell">cool, empowering technologies</a> for them to use. I also thought that pretty much everybody liked Microsoft finally opening up and actually talking TO people&#8230; not only talking them INTO buying something, something &#8211; but having real conversations.</p>
<p>I get sad when I find that people still don&#039;t seem to be accepting that, and wanting back the old model, instead. Kinda weird.</p>
<p>&nbsp;</p>
<p>The conversation goes as follows (words are not exactly those &#8211; we were speaking Italian and I sort of reconstructed the conversation &#8211; you should get the sense of it anyway):</p>
<p>&nbsp;</p>
<blockquote><p>[...]</p>
<p><strong>Me:</strong> &#034;The SDK service allows you to do quite a lot of cool stuff. Unfortunately not all of that functionality is completely or always easily exposed in the GUI. That is, for example: it is very EASY to define overrides, but it can get very tricky to find them back once set. That&#039;s why you can use <a href="http://blogs.msdn.com/boris_yanushpolsky/archive/2007/08/09/override-explorer-v3-3.aspx">this little useful tool</a> that the developer of that SDK service has posted on his blog&#8230;&#034; </p>
<p><strong>Cust:</strong> &#034;&#8230;but we can&#039;t just read blogs here and there!&#034; </p>
<p><strong>Me:</strong> &#034;Well, I mean, then you may have to wait for the normal release cycle. It might be that those improvements will make it in to the product. That might happen in months, if you are lucky, or maybe never. What&#039;s wrong if he publishes that on his blog, bypassing the bureaucracy crap, and makes your life easier with it RIGHT NOW?&#034; </p>
<p><strong>Cust:</strong> &#034;It is not official, I want it in the product!&#034; </p>
<p><strong>Me:</strong> &#034;I see, and even understand that. But right now that feature just isn&#039;t there. But you can use this tool to have it. Don&#039;t worry: it is not made by some random guy who wants to trojan your server! It is made by the very same developer who wrote the product itself&#8230;&#034; </p>
<p><strong>Cust:</strong> &#034;It is not supported, what if it breaks something?&#034; </p>
<p><strong>Me: </strong>&#034;So are all resource kit tools, in general. written by some dev guy in his free five minutes, and usually unsupported. Still very useful, though. Most of them. And they usually do work, you know that much, don&#039;t you?&#034; </p>
<p><strong>Cust:</strong> &#034;But why on a blog?&#034; </p>
<p><strong>Me:</strong> &#034;What&#039;s wrong with this? People are just trying to make customer&#039;s life easier by <a href="http://www.gapingvoid.com/Moveable_Type/archives/001607.html">being transparent and open and direct in their communication, just talking RIGHT to the customers. People talking to people</a>, bypassing the prehistoric bureaucracy structure of companies&#8230; the same happens on many other sites, just think <a href="http://isatools.org/">isatools.org</a> for example&#8230; those are just tools that a support guy like me has written and wants to share because they might be useful&#8230;&#034; </p>
<p><strong>Cust:</strong> &#034;But I can&#039;t follow/read all the blogs out there! I don&#039;t have time for it&#034; </p>
<p><strong>Me:</strong> &#034;Why not? I have thousands of feeds in my aggregator and&#8230;&#034; </p>
<p><strong>Cust:</strong> &#034;I don&#039;t have time and I don&#039;t want to read them, because I pay for support, so I don&#039;t expect this stuff to be in blogs&#034; </p>
<p><strong>Me:</strong> &#034;Well, I see, since you pay for support, you are paying ME &#8211; in fact I am working with you on this product precisely as part of that paid support. That&#039;s why I am here to tell you that this tool exists, in case you had not heard of it, so you actually know about it without having to read that yourself on any blog&#8230; does that sound like a deal? Where&#039;s the issue?&#034; </p>
<p><strong>Cust:</strong> &#034;Sgrunt. I want something official, I don&#039;t like this blog stuff&#034; </p>
<p>[...]</p>
</blockquote>
<p>&nbsp;</p>
<p>I thought this was particularly interesting, not because I want to make fun of this person. I do respect him and I think he just has a different point of view. But in my opinion this conversation shows (and made me think about) an aspect of that &#034;generation gap&#034; inside Microsoft that <a href="http://www.gapingvoid.com/Moveable_Type/archives/004459.html">Hugh talks about here</a>: </p>
<blockquote><p><em>&#034;[...]4.30 Hugh talks about a conversation he had with a few people inside Microsoft- how there’s a generation gap growing within the company, between the Old Guard, and the new generation of Microsofties, who see their company in much more open, organic terms.[...]&#034;</em> </p>
</blockquote>
<p>Basically this tells me that the generation gap is not happening only INSIDE Microsoft: it invests our customers too. Which makes it even more <a href="http://www.gapingvoid.com/Moveable_Type/archives/004181.html">difficult to talk to some of them, as we change</a>. Traditions are hard to change.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2008/03/28/conversation-about-blogs-with-a-customer/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Looking at OpsMgr2007 Alert trend with Command Shell</title>
		<link>http://www.muscetta.com/2008/01/25/looking-at-opsmgr2007-alert-trend-with-command-shell/</link>
		<comments>http://www.muscetta.com/2008/01/25/looking-at-opsmgr2007-alert-trend-with-command-shell/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 20:01:02 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[MOM]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[OpsMgr2007]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[System Center Operations Manager 2007]]></category>
		<category><![CDATA[Alert]]></category>
		<category><![CDATA[Command Shell]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[trend]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/2008/01/25/looking-at-opsmgr2007-alert-trend-with-command-shell/</guid>
		<description><![CDATA[It&#039;s friday night, I am quite tired and I can&#039;t be asked of writing a long post. But I have not written much all week, not even updated my Twitter, and now I want to finish the week with at least some goodies. So this is the turn of a couple of Powershell commands/snippets/scripts that [...]<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p>It&#039;s friday night, I am quite tired and I can&#039;t be asked of writing a long post. But I have not written much all week, not even updated my Twitter, and now I want to finish the week with at least some goodies. So this is the turn of a couple of <a href="http://www.microsoft.com/powershell">Powershell</a> commands/snippets/scripts that will count alerts and events generated each day: this information could help you understand the trends of events and alerts over time in a Management Group. It is nothing fancy at all, but they can still be useful to someone out there. In the past (MOM 2005) I used to gather this kind of information with SQL Queries against the operations database. But now, with Powershell, everything is exposed as objects and it is much easier to get information without really getting your hands dirty with the database <img src='http://www.muscetta.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>#Number of Alerts per day</strong></p>
<p><em>$alerttimes = Get-Alert | Select-Object TimeRaised<br />
$array=@() </em></p>
<p><em>foreach ($datetime in $alerttimes){<br />
$array += $datetime.timeraised.date<br />
} </em></p>
<p><em>$array | Group-Object Date</em></p>
<p><strong>#Number of Events per day</strong></p>
<p><em>$eventtimes = Get-Event | Select-Object TimeGenerated<br />
$array=@() </em></p>
<p><em>foreach ($datetime in $eventtimes){<br />
$array += $datetime.timegenerated.date<br />
} </em></p>
<p><em>$array | Group-Object Date</em></p>
<p>Beware that these &#034;queries&#034; might take a long time to execute (especially the events one) depending on the amount of data and your retention policy.</p>
<p>This is of course just scratching the surface of the amount of amazing things you can do with Powershell in Operations Manager 2007. For this kind of information you might want to keep an eye on the official &#034;System Center Operations Manager Command Shell&#034; blog: <a href="http://blogs.msdn.com/scshell/" title="http://blogs.msdn.com/scshell/">http://blogs.msdn.com/scshell/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2008/01/25/looking-at-opsmgr2007-alert-trend-with-command-shell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Get-FlickrPhotos</title>
		<link>http://www.muscetta.com/2008/01/14/get-flickrphotos/</link>
		<comments>http://www.muscetta.com/2008/01/14/get-flickrphotos/#comments</comments>
		<pubDate>Mon, 14 Jan 2008 21:46:50 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Blogs]]></category>
		<category><![CDATA[Choice]]></category>
		<category><![CDATA[Cross Post]]></category>
		<category><![CDATA[dotNet]]></category>
		<category><![CDATA[Flickr]]></category>
		<category><![CDATA[Interop]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/2008/01/14/get-flickrphotos/</guid>
		<description><![CDATA[A while ago, talking to some friends, I was mentioning how cool it was that Flickr provides APIs, so that you can always get your data out of it, if you want to. There are several downloader applications that I found on the Internet, but I have not yet chosen one that I completey like [...]<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p>A while ago, talking to some friends, I was mentioning how cool it was that <a href="http://www.flickr.com/services/api">Flickr provides APIs</a>, so that you can always get your data out of it, if you want to. There are several downloader applications that I found on the Internet, but I have not yet chosen one that I completey like among the few that I&#039;ve tried. So, inspired by <a href="http://kosso.wordpress.com/2007/01/31/free-php5-script-to-grab-your-flickr-photos/">Kosso&#039;s PHP script for enumerating your photos on Flickr</a>, I thought I&#039;d port it to <a href="http://www.microsoft.com/powershell">Powershell</a> and make my own version of it. Just for the fun of it. My Powershell script does not do everything that Kosso&#039;s one does: I don&#039;t build a web page showing description and comments. I suppose this is because the original script was made with PHP, which you usually run on a web server and outputting as HTML is the standard thing you would do in PHP. I just concentrated on the &#034;download&#034; thing, since mine it is a console script. You can think of mine as a &#034;full backup&#034; script. Full&#8230; well, at least of all your photos, if not of all the metadata. It should be trivial to extend anyway, also considering Powershell XML type accelerator really makes it extremely easy to parse the output of a <a href="http://www.flickr.com/services/api/request.rest.html">REST API such as Flickr&#039;s</a> (I would say even easier and more readable that PHP&#039;simplexml). There is a ton of things that could be extended/improved in the script&#8230; including supporting proxy servers, accepting more parameters for things that are now hardcoded&#8230; and with a million other things. Even this way, though, I think that the script can be useful to show a number of techniques in Powershell. Or just to download your photos <img src='http://www.muscetta.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  So you can download the script from here: <a href="http://www.muscetta.org/Get-FlickrPhotos.ps1.txt">Get-FlickrPhotos.ps1</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2008/01/14/get-flickrphotos/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Welcome www.powershell.it!</title>
		<link>http://www.muscetta.com/2008/01/04/welcome-wwwpowershellit/</link>
		<comments>http://www.muscetta.com/2008/01/04/welcome-wwwpowershellit/#comments</comments>
		<pubDate>Fri, 04 Jan 2008 21:35:50 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Blogs]]></category>
		<category><![CDATA[Choice]]></category>
		<category><![CDATA[Cross Post]]></category>
		<category><![CDATA[dotNet]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[Interop]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/2008/01/04/welcome-wwwpowershellit/</guid>
		<description><![CDATA[I just read from Jeffrey Snover about this newly born Italian PowerShell community site. I just created an account for myself on the site&#8230; as you know I like PowerShell, so even if I usually prefer writing stuff in english, I will try to hang out there and see how can I contribute to it. [...]<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p>I <a href="http://blogs.msdn.com/powershell/archive/2008/01/04/www-powershell-it-italian-powershell-community-website.aspx">just read from Jeffrey Snover</a> about this newly born <a href="http://www.powershell.it/">Italian PowerShell community site</a>.</p>
<p>I just created an account for myself on the site&#8230; as you know <a href="http://www.muscetta.com/category/powershell/">I like PowerShell</a>, so even if I usually prefer writing stuff in english, I will try to hang out there and see how can I contribute to it.</p>
<p>After all, I am italian&#8230; <img src='http://www.muscetta.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2008/01/04/welcome-wwwpowershellit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simply Works</title>
		<link>http://www.muscetta.com/2007/12/27/simply-works/</link>
		<comments>http://www.muscetta.com/2007/12/27/simply-works/#comments</comments>
		<pubDate>Thu, 27 Dec 2007 18:24:27 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[MOM]]></category>
		<category><![CDATA[MOM2005]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[OpsMgr2007]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Photos]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[System Center Operations Manager 2007]]></category>
		<category><![CDATA[Blogs]]></category>
		<category><![CDATA[Choice]]></category>
		<category><![CDATA[Energy]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[lifestream]]></category>
		<category><![CDATA[Risk]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/2007/12/27/simply-works/</guid>
		<description><![CDATA[Simply Works, uploaded by Daniele Muscetta on Flickr. I don&#039;t know about other people, but I do get a lot to think when the end of the year approaches: all that I&#039;ve done, what I have not yet done, what I would like to do, and so on&#8230; And it is a period when memories [...]<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p class="flickr-frame"><a title="photo sharing" href="http://www.flickr.com/photos/dani3l3/2141526220/"><img src="http://farm3.static.flickr.com/2222/2141526220_7754fa3134.jpg" alt="Simply Works" class="flickr-photo" /></a></p>
<p><span class="flickr-caption"><a href="http://www.flickr.com/photos/dani3l3/2141526220/">Simply Works</a>, uploaded by <a href="http://www.flickr.com/people/dani3l3/">Daniele Muscetta</a> on Flickr.</span></p>
<p class="flickr-yourcomment">I don&#039;t know about other people, but I do get a lot to think when the end of the year approaches: all that I&#039;ve done, what I have not yet done, what I would like to do, and so on&#8230;</p>
<p>And it is a period when memories surface.</p>
<p>I found the two old CD-ROMs you can see in the picture. And those are memories.<br />
missioncritical software was the company that invented a lot of stuff that became Microsoft&#039;s products: for example <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=6f86937b-533a-466d-a8e8-aff85ad3d212&amp;displaylang=en">ADMT</a> and <a href="http://www.microsoft.com/systemcenter/opsmgr/default.mspx">Operations Manager</a>.</p>
<p>The black CD contains SeNTry, the &#034;enterprise event manager&#034;, what later became Operations Manager.<br />
On the back of the CD, the company motto at the time: &#034;software that works simply and simply works&#034;.<br />
So true. I might digress on this concept, but I won&#039;t do that right now.</p>
<p>I have already explained in my other blog <a href="http://blogs.msdn.com/dmuscett/archive/2005/09/02/459914.aspx">what I do for work</a>. Well, that was a couple of years ago anyway. Several things have changed, and we are moving towards offering services that are more measurable and professional. So, since it happens that in a certain job you need to be an &#034;expert&#034; and &#034;specialize&#034; in order to be &#034;seen&#034; or &#034;noticed&#034;.<br />
You know <a href="http://www.muscetta.com/2006/05/29/specialization-is-bullshit/">I don&#039;t really believe in specialization</a>. I have written it <a href="http://www.muscetta.com/2006/11/05/more-on-specialization/">all over the place</a>. But you need to make other people happy as well and let them believe what they want, so when you &#034;specialize&#034; they are happier. No, really, it might make a difference in your carrer <img src='http://www.muscetta.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>In this regard, I did also mention my <a href="http://blogs.msdn.com/dmuscett/archive/2004/11/18/263280.aspx">&#034;meeting again&#034; with Operations Manager</a>.<br />
That&#039;s where Operations manager helped me: it let me &#034;specialize&#034; in systems and applications management&#8230; a field where you need to know a bit of everything anyway: infrastructure, security, logging, scripting, databases, and so on&#8230; <img src='http://www.muscetta.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
This way, everyone wins.</p>
<p>Don&#039;t misunderstand me, this does not mean I want to know everything. One cannot possibly know everything, and the more I learn the more I believe I know nothing at all, to be honest. I don&#039;t know everything, <a href="http://thedailywtf.com/Articles/Classic-WTF-Lock-In-Key-Security.aspx">so please don&#039;t ask me everything &#8211; I work with mainframes</a> <img src='http://www.muscetta.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
While that can be a great excuse to avoid neighbours and relatives annoyances with their PCs though, on the serious side I still believe that any intelligent individual cannot be locked into doing a narrow thing and know only that one bit just because it is common thought that you have to act that way.</p>
<p>If I would <a href="http://twitter.com/gapingvoid/statuses/535752142">stop where I have to stop</a> I would be the standard &#034;IT Pro&#034;. I would be fine, sure, but I would get bored soon. I would not learn anything. <a href="http://www.muscetta.com/2007/09/11/itpro-vs-dev-there-is-no-such-a-thing/">But I don&#039;t feel I am the standard &#034;IT Pro&#034;</a>. In fact, funnily enough, <a href="http://www.google.com/search?hl=en&amp;q=link:www.muscetta.com&amp;btnG=Search">on some other blogs out there I have been referenced as a &#034;Dev&#034;</a> (find it on your own, look at their blogrolls <img src='http://www.muscetta.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> ). But I am not a Dev either then&#8230; I don&#039;t write code for work. I would love to, but I rarely actually do, other than some scripts. Anyway, I tend to escape the definition of the usual &#034;expert&#034; on something&#8230; mostly because I want to escape it. I don&#039;t see myself represented by those generalization.</p>
<p>As <a href="http://haacked.com/archive/2007/12/21/faceoff-haack-vs-hanselman-it-gets-real.aspx">Phil puts it</a>, when asked &#034;Are software developers &#8211; engineers or artists?&#034;:</p>
<blockquote><p>&#034;[...] Don’t take this as a copout, but a little of both. I see it more as craftsmanship. Engineering relies on a lot of science. Much of it is demonstrably empirical and constrained by the laws of physics. Software is less constrained by physics as it is by the limits of the mind. [...]&#034;</p></blockquote>
<p>Craftmanship. Not science.<br />
And stop calling me an &#034;engineer&#034;. I am not an engineer. I was even crap in math, in school!</p>
<p>Anyway, what does this all mean? In practical terms, it means that in the end, wether I want it or not, I do get considered an &#034;expert&#034; on MOM and OpsMgr&#8230; and that I will mostly work on those products for the next year too. But that is not bad, because, as I said, working on that product means working on many more things too. Also, I can point to different audiences: those believing in &#034;experts&#034; and those going beyond schemes. It also means that I will have to continue teaching a couple of scripting classes (both VBScript and PowerShell) that nobody else seems to be willing to do (because they are all *expert* in something narrow), and that I will still be hacking together my other stuff (my facebook apps, my wordpress theme and plugins, my server, etc) and even continue to have strong opinions in those other fields that I find interesting and where I am not considered an *expert* <img src='http://www.muscetta.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Well, I suppose I&#039;ve been ranting enough for today&#8230;and for this year <img src='http://www.muscetta.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
I really want to wish everybody again a great beginning of 2008!!! What are you going to be busy with, in 2008 ?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2007/12/27/simply-works/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ITPro vs. Dev: there is no such a thing.</title>
		<link>http://www.muscetta.com/2007/09/11/itpro-vs-dev-there-is-no-such-a-thing/</link>
		<comments>http://www.muscetta.com/2007/09/11/itpro-vs-dev-there-is-no-such-a-thing/#comments</comments>
		<pubDate>Tue, 11 Sep 2007 19:05:49 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Cross Platform]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Blogs]]></category>
		<category><![CDATA[Choice]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/2007/09/11/itpro-vs-dev-there-is-no-such-a-thing/</guid>
		<description><![CDATA[Dave Winer wisely writes: [...] I&#039;ve been pushing the idea that every app should be a platform for a long time, that in addition to a user interface, every app should have a programmatic interface. For me the idea came from growing up using Unix in the 70s, where every app is a toolkit and [...]<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.scripting.com/stories/2007/09/10/shouldEveryAppBeAPlatform.html">Dave Winer wisely writes</a>:</p>
<blockquote><p><em>[...] I&#039;ve been pushing the idea that every app should be a platform for a long time, that in addition to a user interface, every app should have a programmatic interface. For me the idea came from growing up <strong>using Unix</strong> in the 70s, <strong>where every app is a toolkit and the operating system is a scripting language</strong>. Wiring things together is an integral part of being a Unix user. It&#039;s why programmers like Unix so much [...]</em></p></blockquote>
<p>It is entirely true. The limits are blurry, IMHO. In the Unix world it is common to find full-fledged &#034;applications&#034; which have been written by the ground up by people that were doing SysAdmin tasks, and those &#034;applications&#034; are usually just&#8230; scripts. Simple shell scripts, or something more evolved (PERL, PHP, Python) it does not really matter.</p>
<p>I am so tired of the division traditionally made in the Microsoft world between &#034;Developers&#034; and &#034;IT Professionals&#034;. We even have separate sites for the two audiences: <a href="http://msdn.microsoft.com">MSDN</a> and <a href="http://technet.microsoft.com">Technet</a>. There are separate &#034;TechED&#034; events: for&#034;<a href="http://www.mseventseurope.com/teched/07/developers/Content/Pages/Default.aspx">Devs</a>&#034; and for &#034;<a href="http://www.mseventseurope.com/teched/07/itforum/Content/Pages/Default.aspx">IT Pros</a>&#034;. There are blogs that are divided among the two &#034;audiences&#034;&#8230;</p>
<p>There aren&#039;t two different audiences, really. There are people, with various degrees of expertise. There is no such a thing as a &#034;developer&#034; if he doesn&#039;t know a bit how the underlying system works. His code is gonna suck. And there is not such a thing such a &#034;IT Pro&#034; that builds and integrates and manages systems if he does not have the palest idea of how things work &#034;behind the GUI&#034;. He&#039;s gonna screw things up regardless of how many step-by-step (click-by-click ?) procedures you spoon feed him.</p>
<p>That&#039;s why automation and integration are best done by people who know how to write a bit code.</p>
<p>The <a href="http://www.microsoft.com/powershell">PowerShell</a> <a href="http://blogs.msdn.com/PowerShell/">folk</a> GET IT.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2007/09/11/itpro-vs-dev-there-is-no-such-a-thing/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Powershell and RegExp: a &quot;match&quot; made my day.</title>
		<link>http://www.muscetta.com/2007/08/09/powershell-and-regexp-a-match-made-my-day/</link>
		<comments>http://www.muscetta.com/2007/08/09/powershell-and-regexp-a-match-made-my-day/#comments</comments>
		<pubDate>Thu, 09 Aug 2007 18:45:31 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[ISA]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/2007/08/09/powershell-and-regexp-a-match-made-my-day/</guid>
		<description><![CDATA[Today I was working with a customer and friend (Claudio Latini, who I thank for the permission to post this, which is also work of his brain &#8211; especially the regular expression you&#039;ll see reading on!). We are running several projects and activities together and, among several other things, he&#039;s in the process of migrating his users from [...]<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p>Today I was working with a customer and friend (Claudio Latini, who I thank for the permission to post this, which is also work of his brain &#8211; especially the regular expression you&#039;ll see reading on!).</p>
<p>We are running several projects and activities together and, among several other things, he&#039;s in the process of migrating his users from Exchange 2003 to Exchange 2007. In this infrastructure, he has some ISA Server that publish both the Exchange2003 and the Exchange2007 frontends.</p>
<p>Now he wanted to know HOW MANY and WHICH ONES of his users actually have a PocketPC or other WIndows Mobile device and were actively connecting to the old FrontEnd. You give out mobile devices to people but those things are usually less &#034;managed&#034; &#8211; when compared to corporate PCs, at least. So you loose a bit control of the thing&#8230; usually people with mobile devices using ActiveSync in companies are managers, and especially since some of them might be on holiday at the moment, it was important to know WHO were the people that had to be told to reconfigure their device to point to the new name/server BEFORE he would start complaining about ActiveSync not working anymore&#8230;</p>
<p>So how do you figure out who&#039;s connecting ?</p>
<p>I am NO Exchange expert whatsoever&#8230; but a thing that came in handy was the thing that an ISA Server was reverse-publishing the frontend server. I know ISA (and firewalls/proxies in general) much better than Exchange, so I can help on that side. In the log files, ActiveSync Connections looked like the following URL, passing most parameters in the POST request: <a title="http://www.company.com/exchange?User=Mario&amp;DeviceID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla" href="http://www.muscetta.org/Admin">http://www.company.com/exchange?User=Mario&amp;DeviceID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla</a> (and on an unrelated note: yes, if you try to crawl this link, you are a bot <img src='http://www.muscetta.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> )</p>
<p>So we exported ISA logs (there are several tools for this, including &#034;<a href="http://www.isatools.org/tools/ISA_Extract_Logs_v1.8.zip">Extract logs</a>&#034;, but we did not use a script, we just used a filter for the correct publishing rule in the &#034;Monitoring &#8211; Logging&#034; tag in ISA Server Console and then copied and pasted those log lines) and tried to see if <a href="http://www.microsoft.com/powershell">PowerShell</a> could help tackle the issue.</p>
<p>Here we load our sample log (in a real log you would have much more information &#8211; each single line wrapping several console rows; I cut it short to the URL to make it more readable.</p>
<pre style="color: #eeedf0; background-color: #012456"><span style="background-color: #012456; color: #00ff00;">PS&gt;</span> get-content log.txt    

http://www.company.com/exchange?User=Mario&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Gino&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Antonio&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Antonio&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Gino&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Antonio&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Antonio&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Mario&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Mario&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Mario&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Mario&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Antonio&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Antonio&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Mario&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Antonio&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Antonio&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Mario&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Antonio&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Antonio&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Mario&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Antonio&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Antonio&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla

http://www.company.com/exchange?User=Mario&amp;DevideID=186hkjw6gjw76463uh2g5gi2j3h&amp;Bla=bla</pre>
<p>We know Get-Content does not just display the file, it loads the file into a string array.</p>
<p>So we can cycle through the file and try to extract (using a regexp) the string after &#034;User=&#034; and before the first ampersand (&#034;&amp;&#034;), which translates in the following regular expression:</p>
<p><strong>&#034;User=(?&lt;nome&gt;.*?)&amp;&#034;</strong></p>
<p>(the regexp has been the most difficult thing to figure out, but it is very worth the hassle once you&#039;ve done it&#8230;)</p>
<pre style="color: #eeedf0; background-color: #012456"><span style="background-color: #012456; color: #00ff00;">PS&gt;</span> get-content log.txt | foreach {$_ -match "User=(?<span>&lt;</span>nome&gt;.*?)&amp;" | out-null; $matches}
Name                           Value
----                           -----
nome                           Mario
0                              User=Mario&amp; nome                           Gino
0                              User=Gino&amp;
nome                           Antonio
0                              User=Antonio&amp;
nome                           Antonio
0                              User=Antonio&amp;
nome                           Gino
0                              User=Gino&amp;
nome                           Antonio
0                              User=Antonio&amp;
nome                           Antonio
0                              User=Antonio&amp;
nome                           Mario
0                              User=Mario&amp;
nome                           Mario
0                              User=Mario&amp;
nome                           Mario
0                              User=Mario&amp;
nome                           Mario
0                              User=Mario&amp;
nome                           Antonio
0                              User=Antonio&amp;
nome                           Antonio
0                              User=Antonio&amp;
nome                           Mario
0                              User=Mario&amp;
nome                           Antonio
0                              User=Antonio&amp;
nome                           Antonio
0                              User=Antonio&amp;
nome                           Mario
0                              User=Mario&amp;
nome                           Antonio
0                              User=Antonio&amp;
nome                           Antonio
0                              User=Antonio&amp;
nome                           Mario
0                              User=Mario&amp;
nome                           Antonio
0                              User=Antonio&amp;
nome                           Antonio
0                              User=Antonio&amp;
nome                           Mario
0                              User=Mario&amp;
nome                           Mario
0                              User=Mario&amp;</pre>
<p>This seems to work. Now we only have to get the Named Captures called &#034;nome&#034; (containing the user name):</p>
<pre style="color: #eeedf0; background-color: #012456"><span style="background-color: #012456; color: #00ff00;">PS&gt;</span> <strong>get-content log.txt | foreach {$_ -match "User=(?<span>&lt;</span>name&gt;.*?)&amp;" | out-null; $matches["name"]}
</strong>Mario
Gino
Antonio Antonio
Gino
Antonio
Antonio
Mario
Mario
Mario
Mario
Antonio
Antonio
Mario
Antonio
Antonio
Mario
Antonio
Antonio
Mario
Antonio
Antonio
Mario
Mario</pre>
<p>Awesome. Now sort them and remove duplicates. Which is one more command in our pipeline:</p>
<p><strong>get-content log.txt | foreach {$_ -match &#034;User=(?&lt;nome&gt;.*?)&amp;&#034; | out-null; $matches["nome"]} | sort-object -uniq</strong></p>
<pre style="color: #eeedf0; background-color: #012456"><span style="background-color: #012456; color: #00ff00;">P&gt;</span> get-content log.txt | foreach {$_ -match "User=(?<span>&lt;</span>name&gt;.*?)&amp;" | out-null; $matches["name"]} | sort-object -uniq
Antonio
Gino
Mario     

<span style="background-color: #012456; color: #00ff00;">PS&gt;</span>
<span style="background-color: #012456; color: #00ff00;">PS&gt;</span></pre>
<p>Now you can call those three users and tell them to modify their ActiveSync configuration <img src='http://www.muscetta.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2007/08/09/powershell-and-regexp-a-match-made-my-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Death by right-click -&gt; Delete ? Nope. PowerShell.</title>
		<link>http://www.muscetta.com/2007/05/30/death-by-right-click-delete-nope-powershell/</link>
		<comments>http://www.muscetta.com/2007/05/30/death-by-right-click-delete-nope-powershell/#comments</comments>
		<pubDate>Wed, 30 May 2007 09:55:42 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[dotNet]]></category>
		<category><![CDATA[Interop]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/2007/05/30/death-by-right-click-delete-nope-powershell/</guid>
		<description><![CDATA[So at one stage I was testing the RSS reader capabilities of Outlook 2007, and I imported an OPML file with roughly 500 feeds! Of course I was NOT interested in reading ALL of them, and it was causing quite a bit of work to do on my machine to fetch them all and sync [...]<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p>So at one stage I was testing the RSS reader capabilities of Outlook 2007, and I imported an OPML file with roughly 500 feeds! Of course I was NOT interested in reading ALL of them, and it was causing quite a bit of work to do on my machine to fetch them all and sync the content in my mailbox&#8230;</p>
<p>So I figured out it was possible to remove the subscription (from the Tools menu -&gt; Account Settings -&gt; RSS Feeds) but the folders were left there. Now, I didn&#039;t want to have those 500 folders in my mailbox, and I did not even want to die by right-clicking, pressing &#034;delete&#034;, confirming&#8230;. all of this 500 times! No way.</p>
<p>So I wrote this little PowerShell script, I guess it *might* be helpful to someone at one stage, who knows ?</p>
<p>[System.Reflection.Assembly]::LoadWithPartialName(&#039;Microsoft.Office.Interop.Outlook&#039;)<br />
$oApp = New-Object -COM &#039;Outlook.Application&#039;<br />
$rss = $oApp.GetNamespace(&#034;MAPI&#034;).GetDefaultFolder(&#034;olFolderRssFeeds&#034;)<br />
forach ($folder in $rss.Folders)<br />
{<br />
$folder.Delete()<br />
}</p>
<p>Please note that if you don&#039;t have the Office Interop Assemblies installed on your machine, you can&#039;t use the first line. As a result, you will have to change the third line hardcoding the number that represents the RSSFeeds folder, so it would become:</p>
<p>$rss = $oApp.GetNamespace(&#034;MAPI&#034;).GetDefaultFolder(25)</p>
<p>Note: I found out (later, of course) that there is a much more general post on this subject (that is, automating Outlook through PowerShell): <a href="http://www.leeholmes.com/blog/GettingThingsDoneOutlookTaskAutomationWithPowerShell.aspx">http://www.leeholmes.com/blog/GettingThingsDoneOutlookTaskAutomationWithPowerShell.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2007/05/30/death-by-right-click-delete-nope-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Out-Flickr!!</title>
		<link>http://www.muscetta.com/2007/01/10/out-flickr/</link>
		<comments>http://www.muscetta.com/2007/01/10/out-flickr/#comments</comments>
		<pubDate>Wed, 10 Jan 2007 15:02:28 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Cross Platform]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Blogs]]></category>
		<category><![CDATA[Cross Post]]></category>
		<category><![CDATA[dotNet]]></category>
		<category><![CDATA[Flickr]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[Interop]]></category>
		<category><![CDATA[Live]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[WebSite]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/2007/01/10/out-flickr/</guid>
		<description><![CDATA[This is soooo cool! An &#034;Out-Flickr&#034; script for PowerShell: http://abhishek225.spaces.live.com/blog/cns!13469C7B7CE6E911!285.entry<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p>This is soooo cool! An &#034;Out-Flickr&#034; script for PowerShell:</p>
<p><a href="http://abhishek225.spaces.live.com/blog/cns!13469C7B7CE6E911!285.entry">http://abhishek225.spaces.live.com/blog/cns!13469C7B7CE6E911!285.entry</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2007/01/10/out-flickr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Out-Blog!</title>
		<link>http://www.muscetta.com/2006/11/24/out-blog/</link>
		<comments>http://www.muscetta.com/2006/11/24/out-blog/#comments</comments>
		<pubDate>Fri, 24 Nov 2006 11:21:19 +0000</pubDate>
		<dc:creator>Daniele Muscetta</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[Blogs]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Choice]]></category>
		<category><![CDATA[Cross Post]]></category>
		<category><![CDATA[dotNet]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[Interop]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[WebSite]]></category>

		<guid isPermaLink="false">http://www.muscetta.com/2006/11/24/out-blog/</guid>
		<description><![CDATA[[Edited again 25th November -&#160;Jachym gave me some suggestions and insights on the use of parameters, and I slightly changed/fixed the original code I had posted yesterday. There&#160;are still some more things that could be improved, of course, but I'll leave them to the future, next time I'll have time fot it (who knows when [...]<hr /><a href="http://www.muscetta.com/about-me/">About Daniele Muscetta</a><hr />]]></description>
			<content:encoded><![CDATA[<p><span style="color: black">[Edited again 25th November -&nbsp;<a href="http://blog.vyvojar.cz/jachymko/">Jachym</a> gave me some suggestions and insights on the use of parameters, and I slightly changed/fixed the original code I had posted yesterday. There&nbsp;are still some more things that could be improved, of course, but I'll leave them to the future, next time I'll have time fot it (who knows when that will be?)]</span></p>
<p><span style="color: black">This one is a post regarding my first test writing a cmdlet for PowerShell. After a few days since having change my blog&#039;s title to <strong><em>&#034;$daniele.rant | Out-Blog&#034;</em></strong> (where Out-Blog was a fantasy cmdlet name, and the title just meant to mimick PowerShell syntax in a funny way), I stumbled across this wonderful blog post: </span><span style="color: #669966; text-decoration: underline"><a href="http://blog.boschin.it/archive/2006/09/21/4375.aspx">http://blog.boschin.it/archive/2006/09/21/4375.aspx</a></span>&nbsp;<span style="color: black">that describes how to use the assemblies of &#034;Windows Live Writer&#034;. Then I saw the light: I could actually implement an &#034;Out-Blog&#034; cmdlet. I am not sure what this could be useful for&#8230; but I thought it was funny to experiment with. I followed the HOW TO information on this other blog post to guide me through the coding: </span><span style="color: #669966; text-decoration: underline"><a href="http://www.proudlyserving.com/archives/2005/10/lets_all_write_1.html">http://www.proudlyserving.com/archives/2005/10/lets_all_write_1.html</a></span></p>
<p><span style="color: #669966; text-decoration: underline"></span><span style="font-size: 10pt">The result is the&nbsp;</span><span style="font-size: 10pt; color: black">code that follows. you see is pretty much Boschin&#039;s code wrapped into a cmdlet class. Nothing fancy. Just a&nbsp;test. I thought someone might find it interesting. It is provided &#034;AS IS&#034;, mainly for educational purpose (MINE, only&nbsp;mine&#8230;. I&#039;m the one whose education is being improved, not you <img src='http://www.muscetta.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> )</span></p>
<p><span style="font-size: 10pt; font-family: trebuchet ms"></span></p>
<p><img src="http://static.flickr.com/119/304859662_fa52bac956.jpg"/>&nbsp;</p>
<p>&nbsp;</p>
</p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">using</span> System; </p>
<p><span style="color: blue">using</span> System.Collections.Generic; </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">using</span> System.Text; </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">using</span> System.Management.Automation; </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">using</span> WindowsLive.Writer.BlogClient.Clients; </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">using</span> WindowsLive.Writer.BlogClient; </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">using</span> WindowsLive.Writer.CoreServices; </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">using</span> WindowsLive.Writer.CoreServices.Settings; </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">using</span> WindowsLive.Writer.Extensibility.BlogClient; </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">using</span> Microsoft.Win32; </p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">namespace</span> LiveWriterCmdlet </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">Cmdlet</span>(<span style="color: maroon">"out"</span>, <span style="color: maroon">"blog"</span>, SupportsShouldProcess=<span style="color: blue">true</span>)] </p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">public</span> <span style="color: blue">sealed</span> <span style="color: blue">class</span> <span style="color: teal">OutBlogCmdlet</span> : <span style="color: teal">Cmdlet </span></p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">Parameter</span>(Position = 0, Mandatory = <span style="color: blue">true</span>, ValueFromPipeline = <span style="color: blue">false</span>, ValueFromPipelineByPropertyName = <span style="color: blue">true</span>)] </p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">ValidateNotNullOrEmpty</span>] </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">public</span> <span style="color: blue">string</span> Title </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">get</span> { <span style="color: blue">return</span> _title; } </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">set</span> { _title = <span style="color: blue">value</span>; } </p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">private</span> <span style="color: blue">string</span> _title; </p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">Parameter</span>(Position=1,Mandatory=<span style="color: blue">true</span>,ValueFromPipeline=<span style="color: blue">true</span>,ValueFromPipelineByPropertyName=<span style="color: blue">true</span>)] </p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">ValidateNotNullOrEmpty</span>] </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">public</span> <span style="color: blue">string</span> Text </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">get</span> { <span style="color: blue">return</span> _text; } </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">set</span> { _text = <span style="color: blue">value</span>; } </p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">private</span> <span style="color: blue">string</span> _text; </p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">Parameter</span>(Position = 2, Mandatory = <span style="color: blue">true</span>, ValueFromPipeline = <span style="color: blue">false</span>, ValueFromPipelineByPropertyName = <span style="color: blue">true</span>)] </p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">ValidateNotNullOrEmpty</span>] </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">public</span> <span style="color: blue">string</span> BlogApiEndPoint </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">get</span> { <span style="color: blue">return</span> _blogapiendpoint; } </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">set</span> { _blogapiendpoint = <span style="color: blue">value</span>; } </p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">private</span> <span style="color: blue">string</span> _blogapiendpoint; </p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">Parameter</span>(Position = 3, Mandatory = <span style="color: blue">true</span>, ValueFromPipeline = <span style="color: blue">false</span>, ValueFromPipelineByPropertyName = <span style="color: blue">true</span>)] </p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">ValidateNotNullOrEmpty</span>] </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">public</span> <span style="color: blue">string</span> UserName </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">get</span> { <span style="color: blue">return</span> _username; } </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">set</span> { _username = <span style="color: blue">value</span>; } </p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">private</span> <span style="color: blue">string</span> _username; </p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">Parameter</span>(Position = 4, Mandatory = <span style="color: blue">true</span>, ValueFromPipeline = <span style="color: blue">false</span>, ValueFromPipelineByPropertyName = <span style="color: blue">true</span>)] </p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">ValidateNotNullOrEmpty</span>] </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">public</span> <span style="color: blue">string</span> Password </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">get</span> { <span style="color: blue">return</span> _password; } </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">set</span> { _password = <span style="color: blue">value</span>; } </p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">private</span> <span style="color: blue">string</span> _password; </p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">Parameter</span>(Position = 6, Mandatory = <span style="color: blue">false</span>, ValueFromPipeline = <span style="color: blue">false</span>, ValueFromPipelineByPropertyName = <span style="color: blue">true</span>)] </p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">ValidateNotNullOrEmpty</span>] </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">public</span> <span style="color: blue">string</span> ProxyAddress </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">get</span> { <span style="color: blue">return</span> _proxyaddress; } </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">set</span> { _proxyaddress = <span style="color: blue">value</span>; } </p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">private</span> <span style="color: blue">string</span> _proxyaddress; </p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">Parameter</span>(Position = 7, Mandatory = <span style="color: blue">false</span>, ValueFromPipeline = <span style="color: blue">false</span>, ValueFromPipelineByPropertyName = <span style="color: blue">true</span>)] </p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">ValidateNotNullOrEmpty</span>] </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">public</span> <span style="color: blue">int</span> ProxyPort </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">get</span> { <span style="color: blue">return</span> _proxyport; } </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">set</span> { _proxyport = <span style="color: blue">value</span>; } </p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">private</span> <span style="color: blue">int</span> _proxyport; </p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">Parameter</span>(Position = 8, Mandatory = <span style="color: blue">false</span>, ValueFromPipeline = <span style="color: blue">false</span>, ValueFromPipelineByPropertyName = <span style="color: blue">true</span>)] </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">public</span> <span style="color: blue">string</span> ProxyUserName </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">get</span> { <span style="color: blue">return</span> _proxyusername; } </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">set</span> { _proxyusername = <span style="color: blue">value</span>; } </p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">private</span> <span style="color: blue">string</span> _proxyusername; </p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">Parameter</span>(Position = 9, Mandatory = <span style="color: blue">false</span>, ValueFromPipeline = <span style="color: blue">false</span>, ValueFromPipelineByPropertyName = <span style="color: blue">true</span>)] </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">public</span> <span style="color: blue">string</span> ProxyPassword </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">get</span> { <span style="color: blue">return</span> _proxypassword; } </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">set</span> { _proxypassword = <span style="color: blue">value</span>; } </p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">private</span> <span style="color: blue">string</span> _proxypassword; </p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">[</span><span style="color: teal">Parameter</span>(Position = 10, Mandatory = <span style="color: blue">false</span>, ValueFromPipeline = <span style="color: blue">false</span>, ValueFromPipelineByPropertyName = <span style="color: blue">true</span>)] </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">public</span> <span style="color: teal">SwitchParameter</span> Published </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">get</span> { <span style="color: blue">return</span> _published; } </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">set</span> { _published = <span style="color: blue">value</span>; } </p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">private</span> <span style="color: blue">bool</span> _published; </p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">protected</span> <span style="color: blue">override</span> <span style="color: blue">void</span> BeginProcessing() </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">base</span>.BeginProcessing(); </p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: teal">ApplicationEnvironment</span>.Initialize(); </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">if</span> ((ProxyAddress != <span style="color: blue">null</span>) | (ProxyAddress != <span style="color: maroon">&#034;&#034;</span>)) </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: teal">WebProxySettings</span>.ProxyEnabled = <span style="color: blue">true</span>; </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: teal">WebProxySettings</span>.Hostname = ProxyAddress; </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: teal">WebProxySettings</span>.Port = ProxyPort; </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: teal">WebProxySettings</span>.Username = ProxyUserName; </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: teal">WebProxySettings</span>.Password = ProxyPassword; </p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">else</span> </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: teal">WebProxySettings</span>.ProxyEnabled = <span style="color: blue">false</span>; </p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">protected</span> <span style="color: blue">override</span> <span style="color: blue">void</span> ProcessRecord() </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: blue">if</span> (ShouldProcess(Text)) </p>
<p><span style="font-size: 10pt; font-family: courier new">{ </span></p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: teal">ISettingsPersister</span> persister = <span style="color: blue">new</span> <span style="color: teal">RegistrySettingsPersister</span>(<span style="color: teal">Registry</span>.CurrentUser, <span style="color: maroon">@&#034;Software\Windows Live Writer&#034;</span>); </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: teal">IBlogCredentials</span> credentials = <span style="color: blue">new</span> <span style="color: teal">BlogCredentials</span>(<span style="color: blue">new</span> <span style="color: teal">SettingsPersisterHelper</span>(persister)); </p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: teal">IBlogCredentialsAccessor</span> credentialsAccessor = <span style="color: blue">new</span> <span style="color: teal">BlogCredentialsAccessor</span>(<span style="color: maroon">&#034;dummy-value&#034;</span>, credentials); </p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">credentials.Username = UserName; </span></p>
<p><span style="font-size: 10pt; font-family: courier new">credentials.Password = Password; </span></p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: teal">MovableTypeClient</span> client = <span style="color: blue">new</span> <span style="color: teal">MovableTypeClient</span>(<span style="color: blue">new</span> <span style="color: teal">Uri</span>(BlogApiEndPoint), credentialsAccessor, <span style="color: teal">PostFormatOptions</span>.Unknown); </p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new"></span><span style="color: teal">BlogPost</span> MyPost = <span style="color: blue">new</span> <span style="color: teal">BlogPost</span>(); </p>
<p><span style="font-size: 10pt; font-family: courier new">MyPost.Title = Title; </span></p>
<p><span style="font-size: 10pt; font-family: courier new">MyPost.Contents = Text; </span></p>
<p><span style="font-size: 10pt; font-family: courier new">client.NewPost(</span><span style="color: maroon">&#034;dummy-value&#034;</span>, MyPost, Published); </p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">WriteVerbose(</span><span style="color: maroon">&#034;Posted Successfully.&#034;</span>); </p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p>&nbsp;</p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
<p><span style="font-size: 10pt; font-family: courier new">} </span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.muscetta.com/2006/11/24/out-blog/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
