<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Tao Yang's System Management Blog</title>
	
	<link>http://blog.tyang.org</link>
	<description>My thoughts on SCOM, SCCM, PowerShell and more...</description>
	<lastBuildDate>Wed, 16 May 2012 12:14:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/TaoYangsSystemManagementBlog" /><feedburner:info uri="taoyangssystemmanagementblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>Powershell: Prevent Users To View and Change Input or Config Files That Are Used by a Script</title>
		<link>http://blog.tyang.org/2012/05/16/powershell-prevent-users-to-view-and-change-input-or-config-files-that-are-used-by-a-script/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-prevent-users-to-view-and-change-input-or-config-files-that-are-used-by-a-script</link>
		<comments>http://blog.tyang.org/2012/05/16/powershell-prevent-users-to-view-and-change-input-or-config-files-that-are-used-by-a-script/#comments</comments>
		<pubDate>Wed, 16 May 2012 12:07:10 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=1230</guid>
		<description><![CDATA[Often, I use .xml or .ini files to store settings that a PowerShell script uses. When I distribute my scripts to end users, sometimes, I want to make sure users cannot manually view or change the content of these config files. Below is what I did to achieve the goal: Create a password protected zip [...]]]></description>
			<content:encoded><![CDATA[<p>Often, I use .xml or .ini files to store settings that a PowerShell script uses. When I distribute my scripts to end users, sometimes, I want to make sure users cannot manually view or change the content of these config files.</p>
<p>Below is what I did to achieve the goal:</p>
<ol>
<li>Create a password protected zip file that contains the config file (.xml or .ini).</li>
<li>rename the zip file from xxxxxx.zip to xxxxxx.bin</li>
<li>In powershell script, use <a href="http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx">ICSharpCode.SharpZipLib.dll</a> to unzip renamed zip file</li>
<li>compile powershell script to exe so users cannot view the script to figure out the zip file password.</li>
<li>read the content of the extracted config file</li>
<li>delete extracted config file</li>
</ol>
<p>To compile the powershell script, I can use one of these tools:</p>
<ul>
<li><a href="http://rkeithhill.wordpress.com/2010/09/21/make-ps1exewrapper/">Make-PS1ExeWrapper</a></li>
<li><a href="http://ps2exe.codeplex.com/">PS2EXE</a></li>
</ul>
<p>Below is a sample Powershell script (Zip-Test.PS1) I have written to read a xml file inside a renamed zip file:</p>
<pre class="brush: powershell; title: ; notranslate">
param ([string]$FilePath)
$ziplib = Join-Path $FilePath &quot;ICSharpCode.SharpZipLib.dll&quot;
[System.Reflection.Assembly]::LoadFrom(&quot;$ziplib&quot;) | Out-Null
$ZipName = &quot;Health-Check.bin&quot;
$XmlName = &quot;Health-Check.xml&quot;
$xmlPath = Join-Path $FilePath $XmlName
$ZipPath = Join-Path $FilePath $ZipName
$objZip = New-Object ICSharpCode.SharpZipLib.Zip.FastZip
$objZip.Password = &quot;password&quot;
$objzip.ExtractZip($ZipPath, $FilePath, $XmlName)
if ((Test-Path $xmlPath))
{
$xml = (get-content $xmlPath)
Remove-Item $xmlPath -Force
}
$xml.configuration
</pre>
<p>The script extracts and reads the health-check.xml file and deletes health-check.xml straightaway, it happens so fast, it won’t be possible for end users to access the file. Below is the output from above sample code (content of my XML file):</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/05/image10.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/05/image_thumb10.png" alt="image" width="580" height="402" border="0" /></a></p>
<p>One thing to keep in mind: in most of my scripts, I use</p>
<pre class="brush: powershell; title: ; notranslate">
$thisScript = Split-Path $myInvocation.MyCommand.Path -Leaf
$scriptRoot = Split-Path (Resolve-Path $myInvocation.MyCommand.Path)
</pre>
<p>To determine the script name and location. $MyInvocation does not work anymore after I converted the Powershell script to EXE. Therefore, from my above example, I’m actually passing the directory location into the script as a parameter.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/05/16/powershell-prevent-users-to-view-and-change-input-or-config-files-that-are-used-by-a-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SCOM PowerShell Snap-in and SDK client with a PowerShell Remote Session</title>
		<link>http://blog.tyang.org/2012/05/09/using-scom-powershell-snap-in-and-sdk-client-with-a-powershell-remote-session/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-scom-powershell-snap-in-and-sdk-client-with-a-powershell-remote-session</link>
		<comments>http://blog.tyang.org/2012/05/09/using-scom-powershell-snap-in-and-sdk-client-with-a-powershell-remote-session/#comments</comments>
		<pubDate>Wed, 09 May 2012 12:11:10 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SCOM]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[PS Remoting]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=1219</guid>
		<description><![CDATA[Recently, I’ve been working on a utility based on PowerShell scripts using WinForms GUI to perform some SCOM tasks (i.e. create maintenance window, approve manually installed agents, adding network devices, etc.). Since this script is going to be widely used in the organisation when it’s completed, I’ve always kept in mind that when users run [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I’ve been working on a utility based on PowerShell scripts using WinForms GUI to perform some SCOM tasks (i.e. create maintenance window, approve manually installed agents, adding network devices, etc.). Since this script is going to be widely used in the organisation when it’s completed, I’ve always kept in mind that when users run this utility, the utility should only connect to SCOM SDK service when required and disconnect as soon as the task is done. In another word, I don’t want this utility to remain connected to the SDK service because Microsoft recommends the concurrent connections should not exceed 50 per management group.</p>
<p>So I did some testing to make sure my scripts disconnects from the RMS SDK service. I opened perfmon on RMS watching the “Client Connections” counter under OpsMgr SDK Service:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/05/image2.png"><img style="display: inline; border-width: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/05/image_thumb2.png" alt="image" width="432" height="345" border="0" /></a></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/05/image3.png"><img style="display: inline; border-width: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/05/image_thumb3.png" alt="image" width="525" height="327" border="0" /></a></p>
<p>and want to make sure the performance counter drops when the script is supposed to disconnect from SCOM management group. In my script, I use both the SCOM PowerShell Snap-in and the SCOM SDK, below is what the code looks like:</p>
<h3><strong>SCOM PowerShell Snap-in:</strong></h3>
<h4><strong>Connect to management group:</strong></h4>
<pre class="brush: powershell; title: ; notranslate">
$RMS = &quot;&lt;RMS Server Name&gt;&quot;

Add-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client
New-PSDrive -Name:Monitoring -PSProvider:OperationsManagerMonitoring -Root:\
Set-Location &quot;OperationsManagerMonitoring::&quot;
new-managementGroupConnection -ConnectionString:$RMS | Out-Null
Set-Location $RMS
</pre>
<p><strong>Disconnect from management group:</strong></p>
<pre class="brush: powershell; title: ; notranslate">
$CurrentMG = get-managementGroupConnection
if ($CurrentMG -ne $null)
{
$CurrentMG | Remove-ManagementGroupConnection | Out-Null
}
</pre>
<h3><strong>SCOM SDK:</strong></h3>
<p><strong>Firstly, Load Assembly:</strong></p>
<pre class="brush: powershell; title: ; notranslate">
[System.Reflection.Assembly]::LoadFrom(&quot;$sdkDir\Microsoft.EnterpriseManagement.OperationsManager.Common.dll&quot;) | Out-Null
[System.Reflection.Assembly]::LoadFrom(&quot;$sdkDir\Microsoft.EnterpriseManagement.OperationsManager.dll&quot;) | Out-Null
</pre>
<p><strong>Connect to management group:</strong></p>
<pre class="brush: powershell; title: ; notranslate">
$UserName = &quot;&lt;user name&gt;&quot;

$UserDomain = &quot;&lt;user domain&gt;&quot;

$password = &quot;&lt;password&gt;&quot;

$securePassword = ConvertTo-SecureString $password –AsPlainText -Force

$MGConnSetting = New-Object Microsoft.EnterpriseManagement.ManagementGroupConnectionSettings($RootMS)
$MGConnSetting.UserName = $UserName
$MGConnSetting.Domain = $UserDomain
$MGConnSetting.Password = $SecurePassword
$ManagementGroup = New-Object Microsoft.EnterpriseManagement.ManagementGroup($MGConnSetting)
</pre>
<p><strong>Disconnect from management group:</strong></p>
<p>I couldn’t find a “disconnect” method for the <a href="http://msdn.microsoft.com/en-us/library/microsoft.enterprisemanagement.managementgroup_methods.aspx">Microsoft.EnterpriseManagement.ManagementGroup</a> object. So I tried to simply remove the variable:</p>
<pre class="brush: powershell; title: ; notranslate">
Remove-Variable ManagementGroup
</pre>
<p>I couldn’t unload the SDK DLLs as I read it’s a limitation in .NET, the only way to unload a loaded DLL is to close the app.</p>
<h3><span style="font-weight: bold;">Test </span><span style="font-weight: bold;">Results:</span></h3>
<p>Regardless which way I use to connect to SCOM (PowerShell Snap-in or SDK), the perf counter does not drop when I tried to disconnect using methods above. In fact, I could only get the counter drop when I close the Powershell console (or exit my GUI app which is just a pure Powershell script).</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/05/image4.png"><img style="display: inline; border-width: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/05/image_thumb4.png" alt="image" width="512" height="318" border="0" /></a></p>
<p>As shown above, notice that as soon as I exit PowerShell, the counter has dropped by 1.</p>
<p>Therefore, I thought I had 2 options to work around this issue.</p>
<p>1. Getting the script to launch another powershell.exe instance when trying to connect to SCOM every time but by doing so, I can’t really pass data / variable back to my script.</p>
<p>2. Use PowerShell Remoting to create a PS Session on local computer, run whatever needs to run against SCOM and remove the PS Session when it’s done. By doing so, I can still pass variables back to my script.</p>
<p>So I’ve decided to go with PowerShell Remoting. I’ve used “<strong>Enable-PSremoting –force</strong>” cmdlet to enable PS Remoting with all default settings.</p>
<p>I’ll use a simple get-agent cmdlet via PS Remoting as example, I’ve written something like this:</p>
<pre class="brush: powershell; title: ; notranslate">
$RMS = &quot;&lt;RMS Server Name&gt;&quot;
$AgentName = &quot;&lt;Agent Computer Name&gt;&quot;
$NewSession = new-pssession
$agent = invoke-command  -session $NewSession -ScriptBlock {
param($RMS,$AgentName)

Add-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client
New-PSDrive -Name:Monitoring -PSProvider:OperationsManagerMonitoring -Root:\
Set-Location &quot;OperationsManagerMonitoring::&quot;
new-managementGroupConnection -ConnectionString:$RMS | Out-Null
Set-Location $RMS
$Agent = Get-Agent | Where-Object {$_.PrincipalName -imatch $AgentName}
$Agent
} -ArgumentList $RMS, $AgentName
Remove-PSSession $NewSession
</pre>
<p>I ran above code using an account that is a domain admin in my test environment and it’s also a SCOM administrator in my management group. But somehow I get this error:</p>
<p><span style="color: #ff0000;">The user does not have sufficient permission to perform the operation.</span></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/05/image5.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/05/image_thumb5.png" alt="image" width="580" height="246" border="0" /></a></p>
<p>After some research, I realised that I have to use the CredSSP (Credential Security Support Provider) authentication to pass my credential from the local Powershell session to the PS Remoting session (in this case, also on my local machine). So I modified my script to use Credssp when creating the new PS Session:</p>
<pre class="brush: powershell; title: ; notranslate">
$me = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name

$NewSession = new-pssession -ComputerName $env:COMPUTERNAME -Authentication Credssp -Credential (Get-Credential $me)
</pre>
<p>It turned out, after the modification, the code still would not work:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/05/image6.png"><img style="display: inline; border-width: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/05/image_thumb6.png" alt="image" width="580" height="342" border="0" /></a></p>
<p>I then found that I will also have to configure the remote session to pass my credential to the remote server again &#8211; in this case, the SDK service in SCOM RMS (second hop). so my credential will be passed from <strong>Local PowerShell session –&gt; PS remote session on the local computer –&gt; SCOM RMS SDK Service</strong>.</p>
<p>In addition to “<strong>Enable-PSRemoting –force</strong>”, I had perform the following to make it work:</p>
<p><strong>1. Enable WinRM CredSSP to allow the second hop:</strong></p>
<h5><strong>Via PowerShell:</strong></h5>
<ul>
<li>Set-Item WSMAN:\localhost\client\auth\credssp –value $true</li>
<li>Set-Item WSMAN:\localhost\service\auth\credssp –value $true</li>
</ul>
<h5><strong>Or Via Group Policy:</strong></h5>
<ul>
<li>Computer Configuration\Administrative Templates\Windows Components\Windows Remote Management (WinRM)\WinRM Client\Allow CredSSP authentication – Set to “Enabled”</li>
<li>Computer Configuration\Administrative Templates\Windows Components\Windows Remote Management (WinRM)\WinRM Service\Allow CredSSP authentication – Set to “Enabled”</li>
</ul>
<p><strong>2. Configure Credentials Delagations</strong></p>
<p>in Group Policy (either domain GPO or local policy), under</p>
<p>Computer Configuration\Administrative Templtes\System\Credential Delegation\Allow Delegating Fresh Credentials<br />
- Set to Enabled</p>
<p>- Add “WSMAN/&lt;local computer name&gt;” to the server list</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/05/image7.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/05/image_thumb7.png" alt="image" width="580" height="527" border="0" /></a></p>
<p>Now, after I updated the group policy (gpupdate /force), the code should just work. As shown below, I have retrieved the agent information using SCOM Powershell Snap-in via a PS remote session.</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/05/image8.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/05/image_thumb8.png" alt="image" width="580" height="333" border="0" /></a></p>
<p>And now if I take a look at the OpsMgr SDK Service “Client Connections” perf counter:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/05/image9.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/05/image_thumb9.png" alt="image" width="580" height="196" border="0" /></a></p>
<p>My script has connected to the SDK service for few seconds then disconnected!</p>
<h3><span style="font-weight: bold;">Conclusion:</span></h3>
<p>My code ended up like this:</p>
<pre class="brush: powershell; title: ; notranslate">
$me = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name

$RMS =  &quot;&lt;RMS Server Name&gt;&quot;
$AgentName = &quot;&lt;Agent Computer Name&gt;&quot;
$NewSession = new-pssession -ComputerName $env:COMPUTERNAME -Authentication Credssp -Credential (Get-Credential $me)
$agent = invoke-command  -session $NewSession -ScriptBlock {
param($RMS,$AgentName)

Add-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client
New-PSDrive -Name:Monitoring -PSProvider:OperationsManagerMonitoring -Root:\
Set-Location &quot;OperationsManagerMonitoring::&quot;
new-managementGroupConnection -ConnectionString:$RMS | Out-Null
Set-Location $RMS
$Agent = Get-Agent | Where-Object {$_.PrincipalName -imatch $AgentName}
$Agent
} -ArgumentList $RMS, $AgentName
Remove-PSSession $NewSession
</pre>
<p>I could not use “localhost” as computer name when creating new PS session (and adding “WSMAN/localhost” in “Allow Delegating Fresh Credentials policy”. It doesn’t work.</p>
<h3><span style="font-weight: bold;">More Reading:</span></h3>
<p>On OpsMgr SDK service client connections counter:</p>
<p><a href="http://blogs.technet.com/b/kevinholman/archive/2008/10/27/how-many-consoles-are-connected-to-my-rms.aspx">http://blogs.technet.com/b/kevinholman/archive/2008/10/27/how-many-consoles-are-connected-to-my-rms.aspx</a></p>
<p><a href="http://thoughtsonopsmgr.blogspot.com.au/2010/12/how-to-get-alert-when-too-many-scom.html">http://thoughtsonopsmgr.blogspot.com.au/2010/12/how-to-get-alert-when-too-many-scom.html</a></p>
<p>On CredSSP , PS Remoting and SCOM PowerShell Cmdlets:</p>
<p><a href="http://blogs.msdn.com/b/powershell/archive/2008/06/05/credssp-for-second-hop-remoting-part-i-domain-account.aspx">http://blogs.msdn.com/b/powershell/archive/2008/06/05/credssp-for-second-hop-remoting-part-i-domain-account.aspx</a></p>
<p><a href="http://blogs.technet.com/b/stefan_stranger/archive/2010/11/02/using-powershell-remoting-to-connect-to-opsmgr-root-management-server-and-use-the-opsmgr-cmdlets.aspx">http://blogs.technet.com/b/stefan_stranger/archive/2010/11/02/using-powershell-remoting-to-connect-to-opsmgr-root-management-server-and-use-the-opsmgr-cmdlets.aspx</a></p>
<p>Additionally, I ran into this free ebook about a week ago, Even though I’m still reading it, it’s a pretty good book: <a href="http://www.lulu.com/shop/don-jones-and-tobias-weltner/secrets-of-powershell-remoting/ebook/product-20087080.html">Secrets of PowerShell Remoting</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/05/09/using-scom-powershell-snap-in-and-sdk-client-with-a-powershell-remote-session/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My Observation on SCCM Clients BITS Settings</title>
		<link>http://blog.tyang.org/2012/05/05/my-observation-on-sccm-clients-bits-settings/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=my-observation-on-sccm-clients-bits-settings</link>
		<comments>http://blog.tyang.org/2012/05/05/my-observation-on-sccm-clients-bits-settings/#comments</comments>
		<pubDate>Fri, 04 May 2012 14:41:49 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[SCCM]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[BITS]]></category>
		<category><![CDATA[GPO]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=1197</guid>
		<description><![CDATA[Yesterday, while we were reviewing the SCCM (2007 R3) client BITS settings at work, we (my team) have some interesting findings with SCCM client’s BITS settings. We found when the BITS bandwidth throttling settings are configured for a SCCM primary site. SCCM clients get the policy and write the settings into Windows local policy: SCCM [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, while we were reviewing the SCCM (2007 R3) client BITS settings at work, we (my team) have some interesting findings with SCCM client’s BITS settings.</p>
<p>We found when the BITS bandwidth throttling settings are configured for a SCCM primary site. SCCM clients get the policy and write the settings into Windows local policy:</p>
<p><strong>SCCM Computer Client Agent BITS Settings:</strong></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/05/image.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/05/image_thumb.png" alt="image" width="367" height="463" border="0" /></a></p>
<p><strong>BITS Settings from SCCM Client’s Windows local policy (</strong>Local Policy –&gt;Computer Configuration –&gt;Administrative Templates –&gt;Network –&gt;Background Intelligent Transfer Service (BITS) –&gt;Limit the maximum network bandwidth for BITS background transfers<strong>):</strong></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/05/image1.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/05/image_thumb1.png" alt="image" width="580" height="448" border="0" /></a></p>
<p>As you can see, the SCCM site setting is identical to SCCM client’s local policy. SCCM 2007 Unleashed has explained the client BITS settings. You can read about it on Google Books <a href="http://books.google.com.au/books?id=dYYKG44dGHQC&amp;pg=PT414&amp;dq=sccm+client+BITS+setting&amp;hl=en&amp;sa=X&amp;ei=qd-jT8_ZCq7vmAWG0qWbCQ&amp;ved=0CDkQ6AEwAA#v=onepage&amp;q&amp;f=false">HERE</a>.</p>
<p>The book did not state and explain the SCCM client actually WRITES the SCCM site’s BITS policy into SCCM client’s Windows local group policy object (GPO). So I did below tests <strong>IN ORDER</strong> in my home <strong>SCCM 2007 R3 AND SCCM 2012</strong> RTM test environments to work out the behaviours of SCCM client and compare SCCM Client’s BITS setting against the above mentioned setting in local policy:</p>
<p><strong>1. SCCM Client BITS setting left as default in SCCM (Not configured).</strong></p>
<ul>
<li>SCCM 2007 Client Computers: BITS policy in local GPO is set to <strong>DISABLED</strong>!</li>
<li>SCCM 2012 Client Computers: Same as SCCM 2007 client computers</li>
</ul>
<p><strong>2. Enable BITS in SCCM Computer Client Agent setting (In 2007, apply to both clients and BDPs, in 2012, just enable it since there is no BDPs in 2012 anymore.), and define some throttling settings. Then trigger machine policy retrieval on SCCM client computers.</strong></p>
<ul>
<li>SCCM 2007 Client Computers: BITS policy in local GPO is ENABLED in throttling settings are set to as same as SCCM policy.</li>
<li>SCCM 2012 Client Computers: Same as SCCM 2007 client computers</li>
</ul>
<p><strong>3. Change BITS throttling settings in SCCM. Then trigger machine policy retrieval on SCCM client computers</strong></p>
<ul>
<ul>
<li>SCCM 2007 Client Computers: BITS policy in local GPO updated accordingly.</li>
<li>SCCM 2012 Client Computers: Same as SCCM 2007 client computers</li>
</ul>
</ul>
<p><strong>4. Change BITS throttling settings in SCCM client’s Windows local policy. Then trigger machine policy retrieval on SCCM client computers.</strong></p>
<ul>
<ul>
<li>SCCM 2007 Client Computers: local policy remained the same after machine policy retrieval.</li>
<li>SCCM 2012 Client Computers: Same as SCCM 2007 client computers</li>
</ul>
</ul>
<p><strong>5. Change BITS throttling settings in SCCM again. Then trigger machine policy retrieval on SCCM client computers.</strong></p>
<ul>
<li>SCCM 2007 Client Computers: local policy was updated again according to SCCM client’s BITS policy.</li>
<li>SCCM 2012 Client Computers: Same as SCCM 2007 client computers</li>
</ul>
<p><strong>Conclusions:</strong></p>
<p>Based on the tests I have performed. I have come to below conclusions:</p>
<ol>
<li>When the SCCM client’s BITS policy is not configured, the  BITS throttling settings OS local policy is set to <strong>DISABLED</strong>, so effectively no BITS throttling is allowed for <strong>ALL</strong> the apps that uses BITS on the SCCM client computer. (i.e. in our case, VMM agent)</li>
<li>Upon SCCM policy change, SCCM client changes local policy with updated settings once it has retrieved the updated policy via SCCM client’s machine policy retrieval (by default runs every 60 minutes).</li>
<li>The SCCM client’s BITS settings are NOT enforced in local policy. i.e. when local policy is manually updated to be different than SCCM client’s policy, SCCM client does not enforce and update local policy. SCCM clients ONLY write to local policy when the SCCM BITS policy is CHANGED on the primary site.</li>
<li>SCCM 2007 clients and SCCM 2012 clients exhibit same behaviour.</li>
</ol>
<p>So, please look out if you have other apps that uses BITS and the bandwidth is throttled. SCCM client would update the local policy without you knowing it.</p>
<p>Alternatively, using a domain GPO to set BITS throttling settings seems like a good idea. By doing so, you can target different SCCM clients more granularly (targeting different OUs, using WMI filters and AD groups to set GPO scopes) whereas in SCCM 2007, this setting is unique across all clients in the primary site. Additionally, domain GPO will override local policy so local policy can be ignored.<!--EndFragment--></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/05/05/my-observation-on-sccm-clients-bits-settings/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using SCOM To Count Logs and Produce Reports</title>
		<link>http://blog.tyang.org/2012/04/27/using-scom-to-count-logs-and-produce-reports/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-scom-to-count-logs-and-produce-reports</link>
		<comments>http://blog.tyang.org/2012/04/27/using-scom-to-count-logs-and-produce-reports/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 13:40:54 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[SCOM]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[MP Authoring]]></category>
		<category><![CDATA[SCOM Reporting]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=1180</guid>
		<description><![CDATA[Recently, I’ve been asked twice to produce daily reports involves counting some kind of logs: Scenario 1: The support team need to count number of Application event log entries of events with a specific event ID. A daily report is required to list the number for each computer. Scenario 2: An application produces a log [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I’ve been asked twice to produce daily reports involves counting some kind of logs:</p>
<p><strong>Scenario 1:</strong></p>
<p>The support team need to count number of Application event log entries of events with a specific event ID. A daily report is required to list the number for each computer.</p>
<p><strong>Scenario 2:</strong></p>
<p>An application produces a log file each day. The support team need to count the number of a specific phrase appeared in previous day’s log file. A daily report is required to list the count number for each computer.</p>
<p>The solution I produced for both scenarios are very similar. so I thought I’d blog this one.</p>
<p><strong>Solution from High level View:</strong></p>
<ol>
<li>Create a rule in the SCOM management pack to run once a day.</li>
<li>Write a script within a rule in the SCOM management pack to count the log</li>
<li>map the count number to performance data and save it in the SCOM operational and data warehouse DB.</li>
<li>design a report for raw performance data in SQL SRS report builder</li>
<li>save the report into the management pack</li>
<li>schedule the report to run and to be emailed out once a day, AFTER the rule has run for the day.</li>
</ol>
<p>In this blog post, I’m not going to go through the steps of creating the custom data source module and the performance collection rule. They are pretty straightforward and the sample management pack can be downloaded <span style="font-size: small;"><a href="http://blog.tyang.org/wp-content/uploads/2012/04/Custom.Log_.Count_.zip">HERE</a></span>.</p>
<p>I will however go through the steps to create the custom report for the data collected by this rule. I’m creating the report rather than using the built-in performance reports from the “Microsoft Generic Report Library” because none of the built-in performance reports support a table format. I don’t want any fancy charts with the report. All I want is a simple list of the raw perf counter values.</p>
<p>Now, let’s briefly go through the data source module and the performance collection rule.</p>
<p><strong><span style="font-size: small;">Data Source Module:</span></strong> contains 2 members: <strong>System.Scheduler</strong> and <strong>Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe</strong>:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image10.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb10.png" alt="image" width="580" height="328" border="0" /></a></p>
<p>The <strong>Microsoft.PowershellPropertyBagTriggerOnlyProbe</strong> contains a powershell script that counts event log entries and pass the count into a PropertyBag:</p>
<pre class="brush: powershell; title: ; notranslate">
#===========================================================================================
# AUTHOR:  Tao Yang
# DATE:    30/01/2012
# Version: 1.0
# COMMENT: Count for a particular event in event log and pass the count to property bag
#===========================================================================================
Param ([int]$TimeFrameInHours, [string]$LogName, [int]$EventID, [string]$EventSource)

$StartTime = (Get-Date).AddHours(-$TimeFrameInHours)
$iEventCount = 0
Try {
$Events = Get-EventLog -LogName $LogName -After $StartTime -Source $EventSource | Where-Object {$_.EventID -eq $EventID}
Foreach ($Event in $Events)
{
If ($Event -ne $null) {$iEventCount++}
}
} Catch {
$iEventCount = 0
}
$ComputerName = (Get-WmiObject Win32_ComputerSystem).Caption
$oAPI = New-Object -ComObject &quot;MOM.ScriptAPI&quot;
$OAPI.LogScriptEvent(&quot;Event-Count.PS1&quot;,9999,0,&quot;Start EventID $EventID Perf Collection Rule. Collecting $EventID events since $starttime...&quot;)
$oBag = $oAPI.CreatePropertyBag()
$oBag.AddValue('ComputerName', $ComputerName)
$oBag.AddValue('EventCount', $iEventCount)
$oBag.AddValue('TimeFrameInHours', $TimeFrameInHours)
$oBag.AddValue('LogName', $LogName)
$oBag.AddValue('EventID', $EventID)
$oBag.AddValue('EventSource', $EventSource)
$oBag
</pre>
<p><span style="font-size: small;"><strong>Performance Collection Rule</strong>:</span> This rule contains:</p>
<p>Data Source: the data source module created previously</p>
<p>Condition Detection: map the event log count in PropertyBag to performance counter</p>
<p>Actions: Write performance data to Operational and DW databases.</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image11.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb11.png" alt="image" width="580" height="577" border="0" /></a></p>
<p><span style="font-size: small;"><strong>Report:</strong></span></p>
<p>Pre-requisites:</p>
<ul>
<li>Install the Performance Report Model in SCOM reporting SSRS. Here’s a detailed instruction (even though it was written for SCOM 2007 SP1, it’s also applies to SCOM 2007 R2): <a title="http://www.systemcentercentral.com/BlogDetails/tabid/143/IndexID/20269/Default.aspx" href="http://www.systemcentercentral.com/BlogDetails/tabid/143/IndexID/20269/Default.aspx">http://www.systemcentercentral.com/BlogDetails/tabid/143/IndexID/20269/Default.aspx</a></li>
<li>Please Note that in above article, it uses Event model as example. The report I’m going to create uses Performance model. so please make sure <strong>Performance.smdl</strong> is uploaded into SCOM Reporting SSRS and configured to use the “<strong>Data Warehouse Main</strong>” data source.</li>
<li>Import the half finished management pack (with the data source module and the perf collection rule) into a SCOM management group (preferably your development environment).</li>
<li>Create an override or simply change the schedule of the rule to run ASAP so the perf data is collected. this is very useful when testing the report later on.</li>
<li></li>
</ul>
<p><strong>Steps of creating the report:</strong></p>
<p>01.Browse to the SCOM Reporting SSRS reports <a href="http://&lt;servername&gt;/reports">http://&lt;servername&gt;/reports</a> URL</p>
<p>02. Launch Report Builder and click “Run” if security warning pops up</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image12.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb12.png" alt="image" width="580" height="201" border="0" /></a></p>
<p>03. In Report Builder, choose the following options in “Getting Started” pane to create a new report:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image13.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb13.png" alt="image" width="207" height="680" border="0" /></a></p>
<p>04. Enter the report title:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image14.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb14.png" alt="image" width="580" height="215" border="0" /></a></p>
<p>05. Drag “Performance Data Raw into the report</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image15.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb15.png" alt="image" width="580" height="311" border="0" /></a></p>
<p>06. Under Performance Data Raw / Object, Drag the “Name” field to the report<a href="http://blog.tyang.org/wp-content/uploads/2012/04/image16.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb16.png" alt="image" width="580" height="462" border="0" /></a></p>
<p>07. Rename the title of each row in the report table:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image17.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb17.png" alt="image" width="422" height="138" border="0" /></a></p>
<p>08. Right click the number under “Event Count”, select “Format…”, and change “Decimal places” to 0</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image18.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb18.png" alt="image" width="438" height="438" border="0" /></a></p>
<p>09. Click the Filter button to create filters:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image19.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb19.png" alt="image" width="580" height="122" border="0" /></a></p>
<p>10. Under <strong>Performance Data Raw \ Performance Rule Instance \ Performance Rule</strong>, drag the “<strong>Rule System Name</strong>” Field to the right and choose the rule I created in the management pack from the list. (Note: the rule name appears on the list because the management pack is already imported into SCOM and this rule has already collected some performance data.)</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image20.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb20.png" alt="image" width="580" height="398" border="0" /></a></p>
<p>11. Click on <strong>Performance Data Raw</strong> and drag “<strong>Date Time</strong>” field to the right</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image21.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb21.png" alt="image" width="580" height="335" border="0" /></a></p>
<p>12. Click on “equals” next to “Date Time” and change it to “After”:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image22.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb22.png" alt="image" width="358" height="259" border="0" /></a></p>
<p>13. Choose “(n) days ago”</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image23.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb23.png" alt="image" width="258" height="351" border="0" /></a></p>
<p>14. Change “(n)” to “2”</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image24.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb24.png" alt="image" width="333" height="67" border="0" /></a></p>
<p>15. Click OK to exit the <strong>Filter Data</strong> window</p>
<p>16. Now, it’s time to test run the report. To do so, use the Run Report button on the top. Here’s the result from my test environment (Note: the date time is in UTC, <strong>NOT</strong> local time):</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image25.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb25.png" alt="image" width="394" height="468" border="0" /></a></p>
<p>17. If you want to make the report prettier (i.e. changing the font colour to pink <img class="wlEmoticon wlEmoticon-smilewithtongueout" src="http://blog.tyang.org/wp-content/uploads/2012/04/wlEmoticon-smilewithtongueout.png" alt="Smile with tongue out" />) or adjust the column width, or adding a company logo, you can click on “Design Report” button and modify the report.</p>
<p>18. Once you are happy with the report, save it to a RDL (report definition) file:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image26.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb26.png" alt="image" width="198" height="276" border="0" /></a></p>
<p>19. Open up the half finished management pack (unsealed) in Authoring Console, go to <strong>Reporting</strong> workspace and create a new report:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image27.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb27.png" alt="image" width="349" height="233" border="0" /></a></p>
<p>20. Give the report an ID:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image28.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb28.png" alt="image" width="371" height="143" border="0" /></a></p>
<p>21. In the “General” tab, give the report a name and target it to “<strong>Microsoft.Windows.Computer</strong>” class</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image29.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb29.png" alt="image" width="392" height="395" border="0" /></a></p>
<p>22. Go to “Definition” tab, click “Load content from file” and select the RDL file you’ve just created.</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image30.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb30.png" alt="image" width="447" height="155" border="0" /></a></p>
<p>23. Once the RDL file is loaded, remove the first line, which is the XML header <strong>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;</strong></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image31.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb31.png" alt="image" width="471" height="477" border="0" /></a></p>
<p>24. Once the first line is removed, go to “Options” tab</p>
<p>25. Make sure “Visible” is set to “true” and “Accessibility” is set to “public”</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image32.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb32.png" alt="image" width="411" height="416" border="0" /></a></p>
<p>26. click apply and OK to exit the window</p>
<p>27. Now that the report is successfully created and tested, if you have changed the schedule of the perf collection rule (either edited the rule directly or created an override), it’s time to change the schedule back.</p>
<p>28. Now, if you want to keep the management pack unsealed, just export the updated management pack with the report into SCOM management group from authoring console. If you want to seal it, do so, and delete the previous unsealed version from the management group first, then import the sealed version into the management group.</p>
<p>I always increase the version number so I can lookup Event ID 1201 in SCOM agent’s Operations Manager log and make sure the updated version of the MP is received:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image33.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb33.png" alt="image" width="423" height="320" border="0" /></a></p>
<p>29. After couple of minutes, if everything goes well, you should be able to see the report in both Operations Console Reporting workspace and also in SCOM Reporting SSRS site:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image34.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb34.png" alt="image" width="516" height="330" border="0" /></a></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image35.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb35.png" alt="image" width="580" height="237" border="0" /></a></p>
<p><span style="color: #ff0000; font-size: small;">Note:</span> In SSRS, you should also see a .mp file in the same folder. I’ve experienced issues where the report does not get updated with the updated MP, which was caused by incorrect .mp file in SSRS directory. Please refer to my <a href="http://blog.tyang.org/2012/03/28/reports-not-updated-in-scom-sql-reporting-service-when-the-management-pack-was-updated/">previous post</a> for details.</p>
<p>30. Schedule the report in SCOM reporting (so it can be emailed out according to a schedule) if you want to. make sure the report schedule is <strong>AFTER</strong> the rule schedule time (i.e. if the rule runs daily at 0:00am, the report schedule should be something like daily at 0:30am) otherwise newly collected data is not included in the report.</p>
<p>That concludes the steps to create the report. Few other things I’d also like to mention:</p>
<ol>
<li>In my case, for the second scenario I mentioned in the beginning (reading log files), the whole process and idea is the same. The only thing different is the script in the Data Source module.</li>
<li>I could have moved the condition detection module (System.Performance.DataGenericMapper) from the rule to the data source module. I didn’t do it because then I can use the same data source module for other purposes later. For example, if later on, the support team comes to me and ask me to generate alerts once the count reaches a threshold, I can simply create a separate rule (or a custom monitor type and a monitor), using the same data source. If the input parameters of the data source is the same as the existing performance collection rule, the data source should only run once for multiple workflows because of the <a href="http://technet.microsoft.com/en-us/library/ff381335.aspx">Cookdown</a> feature.</li>
<li>If the SCOM agent computer is in maintenance mode when the perf collection rule is scheduled to run, no perf data will be collected and the computer will be missing from the report.</li>
<li>In my example, I’m using a PowerShell script. So PowerShell and it’s execution policy needs to be installed / enabled on the SCOM agent computers. if this doesn’t meet your requirement, just modify the module to use a VBscript instead. I’ve <a href="http://blog.tyang.org/2012/01/27/scom-powershell-property-bag-trigger-only-probe-vs-windows-script-property-bag-probe/">blogged previously</a> on how to create trigger only probe action modules for VBScript.</li>
</ol>
<p>Again, the sample MP and the Report Definition RDL file can be downloaded <span style="font-size: small;"><a href="http://blog.tyang.org/wp-content/uploads/2012/04/Custom.Log_.Count_.zip">HERE</a></span>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/04/27/using-scom-to-count-logs-and-produce-reports/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Changing Display Language on Windows 7 Home and Professional Editions</title>
		<link>http://blog.tyang.org/2012/04/27/changing-display-language-on-windows-7-home-and-professional-editions/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=changing-display-language-on-windows-7-home-and-professional-editions</link>
		<comments>http://blog.tyang.org/2012/04/27/changing-display-language-on-windows-7-home-and-professional-editions/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 09:00:14 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[Language]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=1119</guid>
		<description><![CDATA[I bought a laptop for other family members yesterday, it comes with Windows 7 Home Premium. I needed to change the display language from English to Chinese because the main user of this laptop does not speak English. I thought it was a no brainer as I’ve done it before, all I had to do [...]]]></description>
			<content:encoded><![CDATA[<p>I bought a laptop for other family members yesterday, it comes with Windows 7 Home Premium. I needed to change the display language from English to Chinese because the main user of this laptop does not speak English.</p>
<p>I thought it was a no brainer as I’ve done it before, all I had to do was to load another language pack in &#8220;Regional and Language&#8221; in Control Panel. However, I was wrong. apparently this function is available in Windows 7 Ultimate and Enterprise editions.</p>
<p>I didn’t really want to use <a href="http://windows.microsoft.com/en-AU/windows7/products/windows-anytime-upgrade">Windows Anytime Upgrade</a> to upgrade it to Ultimate just so I can change the language. Lucky I found this post: <a href="http://mark.ossdl.de/2009/08/change-mui-language-pack-in-windows-7-home-and-professional/">http://mark.ossdl.de/2009/08/change-mui-language-pack-in-windows-7-home-and-professional/</a></p>
<p>So below is what I’ve done:</p>
<ol>
<li>Download Windows 7 Service Pack 1 language pack (Because the laptop comes with Windows 7 SP1, I had RTM version of the language pack but it didn’t work.) – I downloaded the entire ISO from my TechNet subscription, but there are many blog posts around with the direct link to Windows Update for each individual language (such as this one: <a href="http://www.technize.net/windows-7-sp1-language-packs-direct-download-links-kb2483139/">http://www.technize.net/windows-7-sp1-language-packs-direct-download-links-kb2483139/</a>)</li>
<li>Extracted the downloaded ISO (from TechNet subscription) to C:\Apps\langpacks</li>
<li>in Command prompt:</li>
<ol>
<li>dism /online /add-package /packagepath:C:\Apps\langpacks\zh-cn\lp.cab</li>
<li>bcdedit /set {current} locale zh-cn</li>
<li>bcdboot %WinDir% /l zh-cn</li>
</ol>
<li>Backed up and deleted <strong>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MUI\UILanguages\en-US</strong></li>
<li>Reboot</li>
</ol>
<p><span style="color: #ff0000; font-size: medium;"><strong>Note</strong></span>: if there were any windows updates that were pending to be installed, the install may fail after the language was changed. I had to run <strong>wuauclt /detectnow</strong> so Windows Update agent detects the updates for different language.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/04/27/changing-display-language-on-windows-7-home-and-professional-editions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SCCM 2012 Log Parser: cmtrace.exe</title>
		<link>http://blog.tyang.org/2012/04/17/sccm-2012-log-parser-cmtrace-exe/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sccm-2012-log-parser-cmtrace-exe</link>
		<comments>http://blog.tyang.org/2012/04/17/sccm-2012-log-parser-cmtrace-exe/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 09:35:19 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[SCCM]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=1114</guid>
		<description><![CDATA[In my opinion, THE most used utility (other than SCCM console) for any SCCM administrators / engineers would have to be trace32.exe. Back in SMS and SCCM 2007 days, trace32.exe comes with the SCCM Toolkit, which contains a bunch of other tools. Speaking of my own experience, out of all the tools provided by the [...]]]></description>
			<content:encoded><![CDATA[<p>In my opinion, <strong>THE</strong> most used utility (other than SCCM console) for any SCCM administrators / engineers would have to be <strong>trace32.exe</strong>. Back in SMS and SCCM 2007 days, trace32.exe comes with the <a href="http://www.microsoft.com/download/en/details.aspx?id=9257">SCCM Toolkit</a>, which contains a bunch of other tools.</p>
<p>Speaking of my own experience, out of all the tools provided by the toolkit, trace32.exe is the one I used the most.</p>
<p>Now with SCCM 2012, trace32.exe has been replaced by a new tool called <strong>cmtrace.exe</strong>.</p>
<p>Unlike trace32.exe, cmtrace.exe is actually built-in in SCCM, there is no need to download separate toolkits for it. cmtrace.32 can be found on the SCCM site server, under “<strong>&lt;SCCM Install Dir&gt;\tools\</strong>” folder. Same as it’s predecessor trace32.exe, cmtrace.exe can be copied / redistributed to other locations / computers alone and use as a log parser.</p>
<p>I have also found that trace32.exe actually does not correct parse SCCM 2012 logs. For example, I’m using both trace32.exe and cmtrace.exe to open execmgr.log from a SCCM 2012 client:</p>
<p><strong>trace32.exe:</strong></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image8.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb8.png" alt="image" width="580" height="410" border="0" /></a></p>
<p><strong>cmtrace.exe:</strong></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image9.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb9.png" alt="image" width="580" height="467" border="0" /></a></p>
<p>So, if you are working with SCCM 2012, make sure you use cmtrace.exe rather than the good old trace32.exe. And maybe like me, copy cmtrace32.exe to your local machine and use it from there rather than using it on the server.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/04/17/sccm-2012-log-parser-cmtrace-exe/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Installing SCCM 2012 RTM Secondary Site using A Pre-Installed SQL Express 2008 R2 Instance</title>
		<link>http://blog.tyang.org/2012/04/09/installing-sccm-2012-rtm-secondary-site-using-a-pre-installed-sql-express-2008-r2-instance/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=installing-sccm-2012-rtm-secondary-site-using-a-pre-installed-sql-express-2008-r2-instance</link>
		<comments>http://blog.tyang.org/2012/04/09/installing-sccm-2012-rtm-secondary-site-using-a-pre-installed-sql-express-2008-r2-instance/#comments</comments>
		<pubDate>Sun, 08 Apr 2012 14:15:46 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[SCCM]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SCCM 2012]]></category>
		<category><![CDATA[Secondary Site]]></category>
		<category><![CDATA[SQL Express]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=1100</guid>
		<description><![CDATA[Since System Center 2012 was RTM’d few days ago, I have started updating / migrating my home environment. After I migrated my 2 Hyper-V servers from VMM 2008 R2 to VMM 2012, I have started building a brand new SCCM 2012 environment so I can migrate SCCM 2007 to it. My plan is to install [...]]]></description>
			<content:encoded><![CDATA[<p>Since System Center 2012 was RTM’d few days ago, I have started updating / migrating my home environment. After I migrated my 2 Hyper-V servers from VMM 2008 R2 to VMM 2012, I have started building a brand new SCCM 2012 environment so I can migrate SCCM 2007 to it. My plan is to install a Central Admin site, a child primary site and a Secondary site so I have a simple 3-tier hierarchy like my existing 2007 and 2012 Beta 2 environments.</p>
<p>The Central Admin site and the child primary site installation all went pretty smoothly. But I had some issues when installing the secondary site.</p>
<p>When installing Secondary Site from it’s parent primary, There are two options available for the database:</p>
<ol>
<li>Install and Configure a local copy of SQL Server Express on the secondary site computer</li>
<li>Use an existing SQL Server instance.</li>
</ol>
<p>I wanted to install SQL Express myself so I can control where it’s installed to and locations for data, log and backup files. – This is pretty common and most of SQL DBAs would configure to install SQL on a volume other than C:\ and place data / logs / backups on dedicated and separate disks. By using SCCM to install SQL express for you, you don’t get to choose any of this, which can be pretty annoying.</p>
<p>According to <a href="http://technet.microsoft.com/en-us/library/gg682077.aspx#BKMK_SupConfigSQLDBconfig">Supported Configurations for Configuration Manager</a>, secondary sites supports <strong>SQL Server Express 2008 R2 with SP1 and Cumulative Update 4</strong>. So I downloaded <a href="http://www.microsoft.com/download/en/details.aspx?id=26729">SQL Server 2008 R2 Express With SP1 with Tools (SQLEXPRWT_x64_ENU.exe)</a> and <a href="http://support.microsoft.com/kb/2633146">SQL 2008 R2 Service Pack 1 Cumulative Update 4</a> and installed them in order on my secondary site site server.</p>
<p>Below is what I have customised during the SQL express install:</p>
<ul>
<li>I configured the location for SQL, SQL instance, data files, log files and backup files the way I wanted it.</li>
<li>I selected the SQL instance to use the collation “<strong>SQL_Latin1_General_CP1_CI_AS</strong>”<strong> </strong>because it is the only collation that SCCM supports.</li>
<li>I kept the default secondary site SQL instance name “<strong>CONFIGMGRSEC</strong>” (this name is what’s used if you choose SCCM to install SQL Express for you).</li>
<li>I have given a pre-configured AD group called “ConfigMgr2012 Servers” which contains all SCCM 2012 site servers <strong>sysadmin</strong> rights in SQL Express.</li>
</ul>
<p>After the install, I applied CU4 and all went pretty smoothly.</p>
<p>Now, I tried to push Secondary Site install from the primary site. Under SQL Server setting step, I selected “<strong>Use an existing SQL Server instance</strong>” option and enter the secondary site server’s FQDN under “<strong>SQL server fully qualified domain name</strong>” and “CONFIGMGRSEC” under “<strong>SQL server instance name, if applicable</strong>”. After finishing the wizard, the secondary site install failed during prerequisite checks. I got few errors in regards to the SQL collation is not set to SQL_Latin1_General_CP1_CI-AS:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb.png" alt="image" width="580" height="167" border="0" /></a></p>
<p>This is very strange because all my SQL instances in this hierarchy are set to this collation, and because of this, the setup did not even get kicked off.</p>
<p>Additionally, I also found the following:</p>
<ul>
<li>On the primary site server, in the ConfigMgrSetup.log under System root, I get the following errors:</li>
<ul>
<li><em>CSql Error: Cannot find type data, cannot get a connection.</em></li>
<li>*** [08001][17][Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.</li>
<li>I could use the SQL management studio from Secondary site server to connect to the SQL express instance, but I couldn’t use the SQL management studio from a remote machine to connect to it:</li>
</ul>
</ul>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image1.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb1.png" alt="image" width="574" height="177" border="0" /></a></p>
<p>After spending some time troubleshooting, I got it going. Below is what I have done on the SQL Express instance:</p>
<p>1. I’ve assign “ConfigMgr2012 Servers” group (which I created myself and it contains the primary site server’s computer account) “<strong>dbcreator</strong>” role on top of sysadmin role it already had.</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image2.png"><img style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb2.png" alt="image" width="244" height="210" border="0" /></a></p>
<p>2. I realised by default, after I installed SQL express, TCP/IP protocol is disabled. So I went to<strong> SQL Server Configuration Manager</strong>, under SQL <strong>Server Network Connection</strong> —&gt; Protocols for CONFIGMGRSEC—&gt;TCP/IP, enabled it. I also had to configure the ports for this connection:</p>
<p>I removed 0 from “TCP Dynamic Ports” for each IP and added static port 1433 under “TCP Port”</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image3.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb3.png" alt="image" width="454" height="502" border="0" /></a></p>
<p>After you enabled TCP/IP and changed the port, you will be prompted that you have to restart SQL server service for the change to take effect, so I restarted the SQL service.</p>
<p>After these steps, the prerequisite checks were passed and the Secondary site installation finished successfully.</p>
<p>In summary below are the steps I took to pre-configure a SQL Express instance for SCCM 2012 secondary site:</p>
<ol>
<li>Install SQL Express 2008 R2 with SP1 with Tools</li>
<li>Configure SQL express install directory as per my standard (not on C:\ drive)</li>
<li>Configure SQL Express instance name as “<strong>CONFIGMGRSEC</strong>” as it is default to SCCM secondary site and there’s no reason to change it.</li>
<li>Select “<strong>SQL_Latin1_General_CP1_CI_AS</strong>” as SQL server collation.</li>
<li>Configure data/logs/backups directory</li>
<li>add primary site server’s computer account (or a group containing primary site server’s computer account) as administrator during install</li>
<li>Apply SQL Server 2008 R2 Service Pack 1 Cumulative Update 4 after SQL Express install</li>
<li>Set a limit for amount of memory SQL express can use.</li>
<li>Reboot secondary site server (just to be safe)</li>
<li>give the parent primary site server&#8217;s computer account dbcreator access in SQL Express instance.</li>
<li>Enable TCP/IP for the SQL express instance.</li>
<li>Configure TCP/IP connection port settings.</li>
<li>Restart SQL service.</li>
<li>Initiate Secondary Site install from Primary site (via SCCM console). – Unlike SCCM 2007, secondary site install can no longer be performed by running SCCM setup from secondary site servers.</li>
<li>During setup wizard, choose “Use an existing SQL Server instance”, enter secondary site server’s FQDN and SQL instance name (“CONFIGMGRSEC”). leave site database name and SQL broker port as default.</li>
<li>monitor install status using the SCCM console:</li>
</ol>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image4.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb4.png" alt="image" width="580" height="474" border="0" /></a></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image5.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb5.png" alt="image" width="580" height="405" border="0" /></a></p>
<p>You can also check:</p>
<ul>
<li>C:\ConfigMgrSetup.log on Primary Site server (contains details for Secondary Site install’s prerequisite checks).</li>
<li>C:\ConfigMgrSetup.log on Secondary Site server (contains details for the actual setup).</li>
</ul>
<p>Now, instead of having SQL Express installed and configured by SCCM, I have more control of it so I can align the configuration with my organisation’s standard (if it’s in a real production environment <img class="wlEmoticon wlEmoticon-smile" style="border-style: none;" src="http://blog.tyang.org/wp-content/uploads/2012/04/wlEmoticon-smile.png" alt="Smile" />).</p>
<p>In this case, I have my SQL data file located under F:\SQL_Data\Microsoft SQL Server\MSSQL10_50.CONFIGMGRSEC\MSSQL\DATA:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image6.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb6.png" alt="image" width="580" height="275" border="0" /></a></p>
<p>And log files under G:\SQL_Logs\Microsoft SQL Server\MSSQL10_50.CONFIGMGRSEC\MSSQL\Data:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/04/image7.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/04/image_thumb7.png" alt="image" width="580" height="239" border="0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/04/09/installing-sccm-2012-rtm-secondary-site-using-a-pre-installed-sql-express-2008-r2-instance/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Reports not updated in SCOM SQL Reporting Service When the Management Pack was Updated</title>
		<link>http://blog.tyang.org/2012/03/28/reports-not-updated-in-scom-sql-reporting-service-when-the-management-pack-was-updated/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=reports-not-updated-in-scom-sql-reporting-service-when-the-management-pack-was-updated</link>
		<comments>http://blog.tyang.org/2012/03/28/reports-not-updated-in-scom-sql-reporting-service-when-the-management-pack-was-updated/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 07:49:13 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[SCOM]]></category>
		<category><![CDATA[SCOM Reporting]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=1078</guid>
		<description><![CDATA[I ran into an issue today. I have updated a report in a management pack. After I updated the version number, sealed it and imported the updated management pack into SCOM, the report that I have modified did not get updated in SQL Reporting Service (SRS). Generally, once a new MP is imported into a [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into an issue today. I have updated a report in a management pack. After I updated the version number, sealed it and imported the updated management pack into SCOM, the report that I have modified did not get updated in SQL Reporting Service (SRS).</p>
<p>Generally, once a new MP is imported into a management group, within few minutes, the reports within the MP should be deployed to SRS. This was the case when I updated the very same MP in Development environment, but in Production, I waited few hours and nothing has happened.</p>
<p>After few hours, I finally fix the issue.</p>
<p>For any reports that have been deployed as part of a MP, there should be a .mp file in the SRS folder, like this one:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/03/image4.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/03/image_thumb4.png" alt="image" width="580" height="258" border="0" /></a></p>
<p>In the production environment, the .mp file name from my management pack folder in SRS is different than the one in development environment. I checked other management packs in both Prod and Dev and they all have the same .mp file name.</p>
<p><strong>To fix the issue:</strong> I deleted the .mp file from SRS, restarted the SRS service. Within one minute, the updated report got deployed to SCOM SQL Reporting Service and the .mp file got recreated as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/03/28/reports-not-updated-in-scom-sql-reporting-service-when-the-management-pack-was-updated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>This Blog Has Been Hacked! But Should Be OK Now…</title>
		<link>http://blog.tyang.org/2012/03/26/this-blog-has-been-hacked-but-should-be-ok-now/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=this-blog-has-been-hacked-but-should-be-ok-now</link>
		<comments>http://blog.tyang.org/2012/03/26/this-blog-has-been-hacked-but-should-be-ok-now/#comments</comments>
		<pubDate>Mon, 26 Mar 2012 09:10:04 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[Others]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=1073</guid>
		<description><![CDATA[&#160; Over the last few days, it seems my blog has been hacked. some suspicious malware codes have been injected into the WordPress PHP pages. I have just reinstalled WordPress, changed all the passwords and ran another scan. it came out clean. I have manually checked infected pages, the suspicious codes have bee removed. If [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>Over the last few days, it seems my blog has been hacked. some suspicious malware codes have been injected into the WordPress PHP pages.</p>
<p>I have just reinstalled WordPress, changed all the passwords and ran another scan. it came out clean. I have manually checked infected pages, the suspicious codes have bee removed.</p>
<p>If you are using Google Chrome and saw the warning page when trying to access my blog:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/03/image3.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/03/image_thumb3.png" alt="image" width="580" height="256" border="0" /></a></p>
<p>I have requested Google to review my site again. Hopefully I’ll get my site removed from the blacklist within few days.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/03/26/this-blog-has-been-hacked-but-should-be-ok-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>System Center Configuration Manager (SCCM) 2007 Client Management Pack for SCOM</title>
		<link>http://blog.tyang.org/2012/03/04/system-center-configuration-manager-sccm-2007-client-management-pack-for-scom/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=system-center-configuration-manager-sccm-2007-client-management-pack-for-scom</link>
		<comments>http://blog.tyang.org/2012/03/04/system-center-configuration-manager-sccm-2007-client-management-pack-for-scom/#comments</comments>
		<pubDate>Sun, 04 Mar 2012 10:58:44 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[SCCM]]></category>
		<category><![CDATA[SCOM]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[MP Authoring]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=1057</guid>
		<description><![CDATA[Background Over the time, I have seen some issues and challenges for SCCM administrators to effectively and proactively managing SCCM clients.  I have personally seen and experienced some challenging issues. For example: Silent clients due to the SMS agent host service not running. SCCM Clients are reporting to the incorrect site due to the combination [...]]]></description>
			<content:encoded><![CDATA[<h1><a href="http://blog.tyang.org/wp-content/uploads/2012/03/systemcenter1.png"><img class="alignleft  wp-image-1059" title="systemcenter" src="http://blog.tyang.org/wp-content/uploads/2012/03/systemcenter1.png" alt="" width="201" height="150" /></a>Background</h1>
<p>Over the time, I have seen some issues and challenges for SCCM administrators to effectively and proactively managing SCCM clients.  I have personally seen and experienced some challenging issues. For example:</p>
<ul>
<li>Silent clients due to the SMS agent host service not running.</li>
<li>SCCM Clients are reporting to the incorrect site due to the combination of overlapping boundaries and auto site assignment.</li>
<li>SCCM Clients missing new functionalities due to Missing SCCM hotfixes (i.e. Power Management in SCCM 2007 R3)</li>
<li>Advertisement executions failures</li>
<li>SCCM clients unable to connect to Management Points</li>
<li>BDP configurations inconsistent (A SCCM client is listed as a BDP on the site server but it is not actually configured as BDP)</li>
<li>Newly installed software are not promptly updated in SCCM site database as the hardware inventory only runs weekly by default.</li>
</ul>
<p>During last year’s Christmas period, some of my employers production servers were assigned to an incorrect SCCM site and as a result, some applications were pushed out to these servers during a change freeze period. We only founded it out after the fact and realised some of these servers were reporting to the wrong SCCM sites for months!</p>
<p>This has triggered me to implement a solution so we can proactively monitor the configurations and activities of SCCM 2007 clients so we are alerted before anything bad happens!</p>
<p>I started writing a SCOM management pack for SCCM 2007 clients. It took me few weeks to cover all the issues that my team is facing. Over the last couple of weekends, I have spent a lot of time to re-write / re-brand it and document it so I can actually post this management pack in my blog.</p>
<p>This management pack provides some proactive monitoring and automations for all of above mentioned issues /challenges. Does this sound interesting to you? If so, please continue reading. The documentation and the management pack download link is at the bottom of this article.</p>
<p>So here are some details of the management pack.</p>
<h1><a name="_Toc318657956"></a>Introduction</h1>
<p>System Center Configuration Manager (SCCM) 2007 Client Management Packs 2.0.0.0 provides basic monitoring of SCCM 2007 clients.</p>
<p>This set of management packs is intended fill the gap of the official Microsoft System Center Configuration Manager 2007 management pack and focus monitoring the SCCM clients in SCCM infrastructures. These managements pack also provides ability to implement customised monitors to monitor the configurations and baselines of SCCM clients in your organisation’s SCCM infrastructures according to your organisation’s standard. i.e.</p>
<p>· Monitors SCCM site assignment, make sure SCCM clients are assigned to the correct primary site in a multi-sites environment.</p>
<p>· Monitors SCCM client versions to make sure all required SCCM client hotfixes are applied.</p>
<p>· Monitors and make sure any SCCM clients that should be configured as Branch Distribution Points (BDP) are actually configured as BDP.</p>
<p>· Make sure SCCM Client cache size is configured according to your company’s standard.</p>
<p>There are 2 separate sealed management packs (.MP) in this set:</p>
<p>· <strong>TYANG System Center Configuration Manager 2007 Library</strong></p>
<ul>
<li>Custom Data Source, Probe Action and Write Action modules</li>
<li>Custom monitor types</li>
<li>SCOM console actions for SCCM clients</li>
<li>SCCM client object discovery</li>
</ul>
<p>· <strong>TYANG System Center Configuration Manager 2007 Monitoring</strong></p>
<ul>
<li>Pre-Configured monitors and rules</li>
<li>Folders and Views</li>
</ul>
<h1>Management Pack Overview</h1>
<p>The System Center Configuration Manager 2007 Client Management Packs not only provides various out-of-box preconfigured monitors / rules, but also provides some custom modules / workflows which allow you to build your own monitors to suit your System Center Configuration Manager 2007 environments. These management packs extends what <a href="http://www.microsoft.com/download/en/details.aspx?id=20463"><em>Microsoft System Center Minotoring Pack For Configuration Manager 2007 SP2 v6.0.6000.3</em></a> has to offer for SCCM client monitoring. This includes:</p>
<h2><a name="_Toc318657961"></a>Pre-Configured Monitors and Rules:</h2>
<p>· Recreated the SMS Agent Host service monitor and included diagnostic and recovery task to automatically restart the service when it has stopped.</p>
<p>· Checks the availability of Management Point of which the SCCM client connects to via HTTP response. The SCCM Management Point HTTP Response Monitor runs hourly to check the HTTP response of the active MP for the SCCM client and generates alerts if HTTP error responses received over 2 consecutive times.</p>
<p>· Checks the version of SCCM clients and generates alert if the version number is lower than 4.00.6487.2157 (<a href="http://support.microsoft.com/kb/977384">KB977384</a>, prerequisite for SCCM 2007 R3)</p>
<p>· Checks SCCM Clients Advertisement Execution history every 30 minutes. If there were any advertisements have been executed over the last 30 minutes, trigger Hardware Inventory so any newly installed applications will be inventoried and stored in SCCM site database. Additionally, if any failed advertisement executions are found, a Critical alert is generated.</p>
<h2><a name="_Toc318657962"></a>Custom Modules and Monitor Types:</h2>
<p><strong>1. SCCM Client Property Value Check 2-State Monitor Type</strong>. This monitor type can be used to build monitors to monitor SCCM client properties. (i.e. Monitor any SCCM clients that are not assigned to the correct site or Cache Size is not configured according to your organisation’s standard, etc..)</p>
<p>This monitor type Supports the following Properties:</p>
<ul>
<li>SiteCode (SCCM Client Site Code)</li>
<li>Version (SCCM Client version)</li>
<li>GUID (SCCM client GUID)</li>
<li>ManagementPoint (MP that SCCM client is connected to)</li>
<li>ProxyMP (Proxy MP that SCCM client is connected to)</li>
<li>InternetMP (Internet MP that SCCM client is connected to)</li>
<li>LogsLocation (path to SCCM client log files)</li>
<li>CacheLocation (path to SCCM client cache)</li>
<li>CacheSize (The maximum size of SCCM client cache folder in MB)</li>
<li>HTTPPort (The HTTP Port for SCCM Client)</li>
<li>EnableAutoAssignment (if auto site assignment is enabled (true or false)</li>
<li>AllowLocalAdminOverride (if the SCCM client allows local admin override (true or false))</li>
<li>IsBDP (If the client is a branch distribution point (true or false))</li>
</ul>
<p>This monitor type Supports the following Comparison Operators:</p>
<ul>
<li>eq (Equal to)</li>
<li>ne (Not equal to)</li>
<li>gt (Greater-than)</li>
<li>lt (Less-than)</li>
<li>ge (Greater-than or equal to)</li>
<li>le (Less-than or equal to)</li>
<li>IsNull (Is Null value)</li>
<li>NotNull (Not Null value)</li>
</ul>
<p><strong>2. Write Action module to initiate SCCM client actions</strong></p>
<p><strong>3. Write Action module to repair SCCM client</strong></p>
<p><strong>4. Other Probe Action modules and Data Source modules that were used by pre-configured monitors and rules.</strong></p>
<h2><a name="_Toc318657963"></a>More Comprehensive Object Discoveries</h2>
<p>This SCCM client object discovery in this management pack discovers pretty much every SCCM client properties that are visible in the industry well-known utility <a href="http://sourceforge.net/projects/smsclictr/">SCCM Client Center</a>.</p>
<p>Below is a comparison of the properties that SCCM Client Center can check VS. SCCM Client properties been discovered by this management pack VS. what are been discovered from Microsoft’s official management pack:</p>
<p><strong>SCCM Client Center 2.0.4.0:</strong></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/03/image.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/03/image_thumb.png" alt="image" width="580" height="376" border="0" /></a></p>
<p><strong>System Center Configuration Manager 2007 Client Management Pack v2.0.0.0:</strong></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/03/image1.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/03/image_thumb1.png" alt="image" width="580" height="369" border="0" /></a></p>
<p><strong>Microsoft Official Configuration Manager 2007 SP2 Management Pack v6.0.6000.3:</strong></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/03/image2.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/03/image_thumb2.png" alt="image" width="474" height="200" border="0" /></a></p>
<h2><a name="_Toc318657964"></a>SCOM Agent Actions for SCCM Clients</h2>
<p>A number of SCCM Client actions have been built into this management pack. The following SCCM client actions can be initiated via SCOM Operations Console and Web Console:</p>
<p>· Discovery Data Collection</p>
<p>· File Collection</p>
<p>· Hardware Inventory</p>
<p>· Machine Policy Retrieval Evaluation</p>
<p>· Software Inventory</p>
<p>· Software Metering Usage Report</p>
<p>· Software Updates Agent Assignment Evaluation Cycle</p>
<p>· Software Updates Scan</p>
<p>· SCCM Client Repair</p>
<h1>More information</h1>
<p>The detailed guide for this MP can be downloaded <strong><span style="font-size: medium;"><a title="SCCM 2007 Client Management Pack Guide" href="http://blog.tyang.org/wp-content/uploads/2012/03/System-Center-Configuration-Manager-2007-Client-MP.pdf">HERE</a></span></strong>.</p>
<p>Management Pack Downloads:</p>
<p>From below link, you can download a zip file which contains:</p>
<ol>
<li>Sealed version of TYANG System Center Configuration Manager 2007 Library  management pack(.mp)</li>
<li>Sealed version of TYANG System Center Configuration Manager 2007 Monitoring management pack(.mp)</li>
<li>Unsealed version of TYANG System Center Configuration Manager 2007 Monitoring management pack(.xml)</li>
</ol>
<p>The reason I’m offering the unsealed version of TYANG System Center Configuration Manager 2007 Monitoring management pack is that if you wish to create additional monitors / rules using the workflows in the library MP, you can just build them into the unsealed MP without creating a separate MP (and saves you time to unseal it).</p>
<p>Management Pack Download <span style="font-size: medium;"><strong><a title="SCCM 2007 Client Management Pack Download" href="http://blog.tyang.org/wp-content/uploads/2012/03/TYANG.System.Center.Configuration.Manager.2007.Client.MP_.zip">HERE</a></strong></span>.</p>
<p>As always, if you have any issues / questions / concerns or suggestions, email me! I’ll try to get back to you as soon as I can (even though recently I’ve been pretty busy at work and in my personal life. And that’s why it took me so long to write a blog article for this management pack!)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/03/04/system-center-configuration-manager-sccm-2007-client-management-pack-for-scom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disabling Auto Discovery in SCDPM 2010</title>
		<link>http://blog.tyang.org/2012/03/01/disabling-auto-discovery-in-scdpm-2010/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=disabling-auto-discovery-in-scdpm-2010</link>
		<comments>http://blog.tyang.org/2012/03/01/disabling-auto-discovery-in-scdpm-2010/#comments</comments>
		<pubDate>Thu, 01 Mar 2012 09:28:34 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[SCDPM]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=1043</guid>
		<description><![CDATA[System Center Data Protection Manager is not something I normally play with. Recently, I’ve been dobbed in to troubleshoot an issue with remote sites network performance at work and the issue ended up was caused by Auto Discovery in DPM 2010. So basically, DPM has this built-in function called “Auto Discovery” which queries the domain [...]]]></description>
			<content:encoded><![CDATA[<p>System Center Data Protection Manager is not something I normally play with. Recently, I’ve been dobbed in to troubleshoot an issue with remote sites network performance at work and the issue ended up was caused by Auto Discovery in DPM 2010.</p>
<p>So basically, DPM has this built-in function called “Auto Discovery” which queries the domain controller of its’ own home domain and stores every single domain member servers in its database. This job runs once a day, you can choose the time window of this job, but you can’t really disable it.</p>
<p>One of my colleagues has posted this issue in DPM TechNet forum: <a title="http://social.technet.microsoft.com/Forums/en-US/dpmsetup/thread/df3dc4ae-200a-4778-8a91-1d7e68d564f2/" href="http://social.technet.microsoft.com/Forums/en-US/dpmsetup/thread/df3dc4ae-200a-4778-8a91-1d7e68d564f2/">http://social.technet.microsoft.com/Forums/en-US/dpmsetup/thread/df3dc4ae-200a-4778-8a91-1d7e68d564f2/</a> and I also logged a premier support call with Microsoft. We got 2 very different solutions from TechNet forum and the Microsoft support engineer in China. After evaluating both solutions, I have decided to go with the solution from the TechNet forum since it’s more robust, but make some modifications.</p>
<p>I have made 3 modifications from the original SQL scripts from TechNet forum:</p>
<ol>
<li>The solution from TechNet forum involves creating a custom SQL agent job called ‘Cancel DPM Auto Discovery’ that runs once a day, prior to the DPM Auto Discovery job. I noticed if you manually change the Auto Discovery start time from DPM console, a new SQL agent job for Auto Discovery is created. So I can’t really guarantee that the original schedule for ‘Cancel DPM Auto Discovery’ job is still valid. Therefore, I changed the schedule from daily to hourly, and runs at the 55th minutes of each hour(i.e. 12:55am, 1:55am, 2:55am, etc.). Because the Auto Discovery job can only run at the full hour (1:00am, 2:00am, 3:00am), by changing the schedule, I can make sure no matter what time the Auto Discovery is scheduled to run, the SQL agent job that I have created will always disable it 5 minutes prior to it.</li>
<li>As I mentioned in the forum thread, I had to change the SQL job category to something other than DPM otherwise DPM will delete my job.</li>
<li>Since we have over 2000 DPM servers in the environment, manually running the SQL script on each DPM server is impossible. Therefore I created a PowerShell script to run the SQL scripts and use SCCM to push it out. During testing, I found the SQL script works if I manually run it from SQL management studio, but when running in PowerShell using either System.Data.SqlClient.SqlConnection object or COM ADO object, the script complained about not able to find @owner_sid at the step of creating the job. I fixed it by changing the job owner from “MICROSOFT$DPM$Acct” to “sa”.</li>
</ol>
<p>Below is the SQL Script and the PowerShell script after my modifications.</p>
<p><a title="SQL Script" href="http://blog.tyang.org/wp-content/uploads/2012/03/DPM.zip">SQL Script</a></p>
<p><a title="PowerShell Script" href="http://blog.tyang.org/wp-content/uploads/2012/03/Create-DisableDPMAutoDiscoverySQLJob.zip">PowerShell Script</a></p>
<p><strong><span style="color: #ff0000; font-size: small;">Note:</span></strong> Both SQL script and Powershell script assume the DPM database is configured as default (which is located locally on the DPM server and the SQL instance name is left as default of ‘MSDPM2010’). If your DPM server is located elsewhere, please modify the SQL script and the SQL connection string in the Powershell script accordingly.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/03/01/disabling-auto-discovery-in-scdpm-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SCCM Site Systems and Components Summarizer Reports</title>
		<link>http://blog.tyang.org/2012/02/23/sccm-site-systems-and-components-summarizer-reports/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sccm-site-systems-and-components-summarizer-reports</link>
		<comments>http://blog.tyang.org/2012/02/23/sccm-site-systems-and-components-summarizer-reports/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 04:18:47 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[SCCM]]></category>
		<category><![CDATA[SCCM Reports]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=1035</guid>
		<description><![CDATA[I received an email today from someone who downloaded my SCCM Health Check Script 3.5. He asked me if I can help to modify the script to only display Site Systems and Components status. I thought this can be easily achieved by creating few simple reports inside SCCM. If you are running SCCM 2007 R3 [...]]]></description>
			<content:encoded><![CDATA[<p>I received an email today from someone who downloaded my <a href="http://blog.tyang.org/2012/01/31/sccm-health-check-script-updated-version-3-5/">SCCM Health Check Script 3.5</a>. He asked me if I can help to modify the script to only display Site Systems and Components status.</p>
<p>I thought this can be easily achieved by creating few simple reports inside SCCM. If you are running SCCM 2007 R3 and have Reporting Service Point configured, you can publish these reports to SQL Reporting Services and create some schedules to email out daily.</p>
<p>So I quickly wrote 3 reports:</p>
<p>1. Site Status Overview Report – A high level overview of site status</p>
<p>2. Site System Status Report – Provides same information as what shows under Site System Status in SCCM console.</p>
<p>3. Site Component Status Since 12:00AM Report – Provides same information as what shows under Component Status in SCCM console (assuming the Threshold period setting under Component Status Summarizer setting is left as default of ‘Since 12:00:00 AM’)</p>
<h2><strong>Below are the SQL queries for each report:</strong></h2>
<p><strong>Site Status Overview Report</strong></p>
<pre class="brush: sql; title: ; notranslate">
Select
SiteStatus.SiteCode, SiteInfo.SiteName, SiteStatus.Updated 'Time Stamp',
Case SiteStatus.Status
When 0 Then 'OK'
When 1 Then 'Warning'
When 2 Then 'Critical'
Else ' '
End AS 'Site Status',
Case SiteInfo.Status
When 1 Then 'Active'
When 2 Then 'Pending'
When 3 Then 'Failed'
When 4 Then 'Deleted'
When 5 Then 'Upgrade'
Else ' '
END AS 'Site State'
From V_SummarizerSiteStatus SiteStatus Join v_Site SiteInfo on SiteStatus.SiteCode = SiteInfo.SiteCode
Order By SiteCode
</pre>
<p><strong>Site System Status Report</strong></p>
<pre class="brush: sql; title: ; notranslate">
SELECT distinct
Case v_SiteSystemSummarizer.Status
When 0 Then 'OK'
When 1 Then 'Warning'
When 2 Then 'Critical'
Else ' '
End As 'Status',
SiteCode 'Site Code',
SUBSTRING(SiteSystem, CHARINDEX('\\', SiteSystem) + 2, CHARINDEX('&quot;]', SiteSystem) - CHARINDEX('\\', SiteSystem) - 3 ) AS 'Site System',
REPLACE(Role, 'SMS', 'ConfigMgr') 'Role',
SUBSTRING(SiteObject, CHARINDEX('Display=', SiteObject) + 8, CHARINDEX('&quot;]', SiteObject) - CHARINDEX('Display=',SiteObject) - 9) AS 'Storage Object',
Case ObjectType
When 0 Then 'Directory'
When 1 Then 'SQL Database'
When 2 Then 'SQL Transaction Log'
Else ' '
END AS 'Object Type',
CAST(BytesTotal/1024 AS VARCHAR(49)) + 'MB' 'Total',
CAST(BytesFree/1024 AS VARCHAR(49)) + 'MB' 'Free',
CASE PercentFree
When -1 Then 'Unknown'
When -2 Then 'Automatically grow'
ELSE CAST(PercentFree AS VARCHAR(49)) + '%'
END AS '%Free'
FROM v_SiteSystemSummarizer
Order By 'Storage Object'
</pre>
<p><strong>Site Component Status Since 12:00AM Report:</strong></p>
<pre class="brush: sql; title: ; notranslate">
SELECT distinct
Case v_ComponentSummarizer.Status
When 0 Then 'OK'
When 1 Then 'Warning'
When 2 Then 'Critical'
Else ' '
End As 'Status',
SiteCode 'Site Code',
MachineName 'Site System',
ComponentName 'Component',
Case v_componentSummarizer.State
When 0 Then 'Stopped'
When 1 Then 'Started'
When 2 Then 'Paused'
When 3 Then 'Installing'
When 4 Then 'Re-Installing'
When 5 Then 'De-Installing'
Else ' '
END AS 'Thread State',
Errors 'Errors',
Warnings 'Warnings',
Infos 'Information',
Case v_componentSummarizer.Type
When 0 Then 'Autostarting'
When 1 Then 'Scheduled'
When 2 Then 'Manual'
ELSE ' '
END AS 'Startup Type',
CASE AvailabilityState
When 0 Then 'Online'
When 3 Then 'Offline'
ELSE ' '
END AS 'Availability State',
NextScheduledTime 'Next Scheduled',
LastStarted 'Last Started',
LastContacted 'Last Status Message',
LastHeartbeat 'Last Heartbeat',
HeartbeatInterval 'Heartbeat Interval',
ComponentType 'Type'
from v_ComponentSummarizer
Where TallyInterval = '0001128000100008'
Order By ComponentName
</pre>
<h2>Report Sample Screenshots:</h2>
<p><strong>Site Status Overview Report</strong></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/02/image10.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/02/image_thumb10.png" alt="image" width="580" height="160" border="0" /></a></p>
<p><strong>Site System Status Report</strong></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/02/image11.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/02/image_thumb11.png" alt="image" width="580" height="489" border="0" /></a></p>
<p><strong>Site Components Status Since 12:00AM Report:</strong></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/02/image12.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/02/image_thumb12.png" alt="image" width="580" height="383" border="0" /></a></p>
<p>I’ve exported these reports into a .mof file, which can be downloaded <a title="Site Reports" href="http://blog.tyang.org/wp-content/uploads/2012/02/SiteReports.zip">HERE</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/02/23/sccm-site-systems-and-components-summarizer-reports/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell Script: Remove All Packages From A SCCM Distribution Point</title>
		<link>http://blog.tyang.org/2012/02/19/powershell-script-remove-all-packages-from-a-sccm-distribution-point/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-script-remove-all-packages-from-a-sccm-distribution-point</link>
		<comments>http://blog.tyang.org/2012/02/19/powershell-script-remove-all-packages-from-a-sccm-distribution-point/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 09:19:58 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SCCM]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=1015</guid>
		<description><![CDATA[Often, SCCM administrators found packages still assigned to distribution points that no longer exist. There are scripts available to remove these “orphaned” package distributions via SMS Provider. i.e. This one called DPClean.vbs from TechNet Blog: Removing a retired DP from all your packages. It was written for SMS 2003. I’m not sure if SMS 2003 [...]]]></description>
			<content:encoded><![CDATA[<p>Often, SCCM administrators found packages still assigned to distribution points that no longer exist. There are scripts available to remove these “orphaned” package distributions via SMS Provider. i.e. This one called <strong>DPClean.vbs</strong> from TechNet Blog: <a href="http://blogs.msdn.com/b/rslaten/archive/2006/03/01/removing-a-retired-dp-from-all-your-packages.aspx">Removing a retired DP from all your packages</a>. It was written for SMS 2003.</p>
<p>I’m not sure if SMS 2003 works differently when deleting package distribution via SMS Provider as I don’t have a SMS 2003 environment around that I can test. But, this script may not work in a multi-tiered SCCM environment (multiple primary sites below a central site). This script only tries to remove package distributions from the site where the user entered.</p>
<p>Use my test environment at home as an example to explain the issue with this script in SCCM 2007:</p>
<p>I have a central site (Site Code: CEN, Site Server: ConfigMgr00), a primary site (Site Code: TAO, Site Server: ConfigMgr01) and a secondary site (Site Code: S01, Site Server; ConfigMgr02) reporting to the primary site TAO.</p>
<p>I created a package called “Configure Windows Firewall Service” on my central site CEN. The Package ID is CEN00013:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/02/image.png"><img style="padding-left: 0px; padding-right: 0px; padding-top: 0px; border: 0px;" src="http://blog.tyang.org/wp-content/uploads/2012/02/image_thumb.png" alt="image" width="580" height="254" border="0" /></a></p>
<p>This package has been assigned to 2 distribution points:</p>
<p><strong>ConfigMgr01</strong></p>
<p><strong>MGMT02\Packages$</strong></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/02/image1.png"><img style="padding-left: 0px; padding-right: 0px; padding-top: 0px; border: 0px;" src="http://blog.tyang.org/wp-content/uploads/2012/02/image_thumb1.png" alt="image" width="580" height="191" border="0" /></a></p>
<p>Notice that there is a pad lock symbol next to ConfigMgr01. If you right click <a href="http://blog.tyang.org//\\MGMT02\Packages$">\\MGMT02\Packages$</a>, there is a “Delete” option:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/02/image2.png"><img style="padding-left: 0px; padding-right: 0px; padding-top: 0px; border: 0px;" src="http://blog.tyang.org/wp-content/uploads/2012/02/image_thumb2.png" alt="image" width="563" height="318" border="0" /></a></p>
<p>When right click CONFIGMGR01, “Delete” option is not available:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/02/image3.png"><img style="padding-left: 0px; padding-right: 0px; padding-top: 0px; border: 0px;" src="http://blog.tyang.org/wp-content/uploads/2012/02/image_thumb3.png" alt="image" width="580" height="280" border="0" /></a></p>
<p>This is because even though the package was created on the central site CEN, but this package was assigned to the DP CONFIGMGR01 on the child primary site TAO.</p>
<p>If I get to the package on Child Primary site TAO, there is no pad lock on CONFIGMGR01 and the “Delete” option is available:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/02/image4.png"><img style="padding-left: 0px; padding-right: 0px; padding-top: 0px; border: 0px;" src="http://blog.tyang.org/wp-content/uploads/2012/02/image_thumb4.png" alt="image" width="580" height="302" border="0" /></a></p>
<p>If I use the same way as DPClean.vbs (only in PowerShell this time):</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/02/image5.png"><img style="padding-left: 0px; padding-right: 0px; padding-top: 0px; border: 0px;" src="http://blog.tyang.org/wp-content/uploads/2012/02/image_thumb5.png" alt="image" width="580" height="388" border="0" /></a></p>
<p>I Firstly locate the package distribution from the central site CEN’s SMSProvider, then use delete() method to remove it, I get a “Generic failure” error.</p>
<p>Notice that the properties of the package distribution object, the SourceSite value is “TAO”. it means the package was assigned to the specific DP from site “TAO”.</p>
<p>Now, if I repeat above PowerShell commands on site “TAO”:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/02/image6.png"><img style="padding-left: 0px; padding-right: 0px; padding-top: 0px; border: 0px;" src="http://blog.tyang.org/wp-content/uploads/2012/02/image_thumb6.png" alt="image" width="580" height="292" border="0" /></a></p>
<p>No errors returned as it was successfully deleted.</p>
<p>Now, on the SCCM console:</p>
<p>On TAO:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/02/image7.png"><img style="padding-left: 0px; padding-right: 0px; padding-top: 0px; border: 0px;" src="http://blog.tyang.org/wp-content/uploads/2012/02/image_thumb7.png" alt="image" width="500" height="279" border="0" /></a></p>
<p>On CEN:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/02/image9.png"><img style="padding-left: 0px; padding-right: 0px; padding-top: 0px; border: 0px;" src="http://blog.tyang.org/wp-content/uploads/2012/02/image_thumb9.png" alt="image" width="499" height="270" border="0" /></a></p>
<p>The DP was deleted on both sites.</p>
<p>In conclusion, no matter which method is used (either via GUI or via SMS provider), the package can only be removed from a DP on the site where it was distributed.</p>
<p>I am also facing the issues around how the SCCM environment is operated at work. we have around over 1000 branch DPs across multiple primary sites. These branch DPs often get decommissioned or rebuilt (not by people who manage SCCM). the people who decommission these Branch DPs do not have knowledge on how SCCM environment is setup. I would not expect them to correctly enter the SCCM site server name when running the script.</p>
<p>Therefore I’ve re-written the script in PowerShell. The only parameter this script requires is the name of the distribution point (can be a normal DP, a DP that’s a Server Share or a Branch DP).</p>
<p><strong>Pre-requisites:</strong></p>
<ul>
<li>The SCCM site information are published in AD</li>
<li>Remote registry service is enabled on both management point and the site server.</li>
<li>The account that runs the script needs to have admin access to the management point and site server.</li>
<li>The account that runs the script has access to SMS provider’s WMI namespace root\sms\site_&lt;site code&gt;.</li>
</ul>
<p><strong>How the script works:</strong></p>
<ol>
<li>Search AD for active/accessible SCCM sites</li>
<li>Connect to the management point and site server of each site published in AD and get details of each SCCM site.</li>
<li>Connect to the SMS provider of each discovered primary site and search for the distribution point.</li>
<li>If the distribution point is found, connect the SMS provider of the primary site where the DP belongs to and get a list of all packages that are assigned to this DP. The list of packages assigned to the DP is displayed on the PowerShell console. If nothing is found, the script ends.</li>
<li>For each package distribution that belongs to DP’s home primary site, delete it using the delete() method.</li>
<li>For each package distribution that belongs to other primary sites, search for the site info of that particular site from the list that obtained from step 2, and get the SMS provider server name. Then connect to the SMS provider of the source site and delete the package distribution using delete() method.</li>
<li>details of any successful and failed deletions are displayed on the PowerShell console.</li>
<li>Wait for 15 seconds, repeat step 3 to double check, see if there are still any packages been assigned to the DP.</li>
<li>If there are still packages assigned to the DP, display a message on the PowerShell console with instruction and a SQL query to run against the SCCM site database to remove them from the database (*Note: deleting straight off the database is not supported by Microsoft.)</li>
</ol>
<p><strong>An Issue with the script:</strong></p>
<p>While I was testing the script, I did find an issue (not sure if the issue is with the logics of the script or, with SCCM itself).</p>
<p>I ran the script to delete all packages off a DP located on my secondary site S01. at that time, there were 3 “Install_Pending” packages against this DP. there were assigned to this DP from the central site CEN. The script ran successfully, deleted all packages on this DP from each package distribution’s source site, including these 3 “Install_Pending” packages (from CEN). However, when double check again, these 3 packages still exist in S01’s primary site TAO’s database. So, the deletions have not been replicated from central site CEN to child primary TAO.</p>
<p>This is why I configured the script to display instructions on how to remove them from site database (unsupported way).</p>
<p>The script can be downloaded here: <a href="http://blog.tyang.org/wp-content/uploads/2012/02/Clean-DP.zip">Clean-DP.PS1</a></p>
<p><span style="color: #ff0000;"><strong>*Note:</strong></span> This script DOES NOT remove the actual packages from the hard disks of distribution points. The script does not actually connect to the DP at all. it can run AFTER the DP is decommissioned.</p>
<p>&nbsp;</p>
<p>Please do not hesitate to contact me if you have any issues or questions about this script.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/02/19/powershell-script-remove-all-packages-from-a-sccm-distribution-point/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PowerShell Script: Get SCCM Management Point server name from AD</title>
		<link>http://blog.tyang.org/2012/02/16/powershell-script-get-sccm-management-point-server-name-from-ad/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-script-get-sccm-management-point-server-name-from-ad</link>
		<comments>http://blog.tyang.org/2012/02/16/powershell-script-get-sccm-management-point-server-name-from-ad/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 00:23:05 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SCCM]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=990</guid>
		<description><![CDATA[I wrote this function as a part of a script that I&#8217;m working on. it searches AD for the management point server name for a particular SCCM site: Note: This function uses another function called Get-AllDomains, which I&#8217;ve blogged before here: http://blog.tyang.org/2011/08/05/powershell-function-get-alldomains-in-a-forest/ So make sure you include BOTH functions in your script.]]></description>
			<content:encoded><![CDATA[<p>I wrote this function as a part of a script that I&#8217;m working on. it searches AD for the management point server name for a particular SCCM site:</p>
<pre class="brush: powershell; title: ; notranslate">
Function Get-MPFromAD ($SiteCode)
{
	$domains = Get-AllDomains
	Foreach ($domain in $domains)
	{
		Try {
			$ADSysMgmtContainer = [ADSI](&quot;LDAP://CN=System Management,CN=System,&quot; + &quot;$($Domain.Properties.ncname[0])&quot;)
			$AdSearcher = [adsisearcher]&quot;(&amp;(Name=SMS-MP-$SiteCode-*)(objectClass=mSSMSManagementPoint))&quot;
			$AdSearcher.SearchRoot = $ADSysMgmtContainer
			$ADManagementPoint = $AdSearcher.FindONE()
			$MP = $ADManagementPoint.Properties.mssmsmpname[0]
		} Catch {}
	}

	Return $MP
}
</pre>
<p>Note: This function uses another function called Get-AllDomains, which I&#8217;ve blogged before here: <a href="http://blog.tyang.org/2011/08/05/powershell-function-get-alldomains-in-a-forest/">http://blog.tyang.org/2011/08/05/powershell-function-get-alldomains-in-a-forest/</a> So make sure you include BOTH functions in your script.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/02/16/powershell-script-get-sccm-management-point-server-name-from-ad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell Script: Calculate First and Last IP of a Subnet</title>
		<link>http://blog.tyang.org/2012/02/09/powershell-script-calculate-first-and-last-ip-of-a-subnet/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-script-calculate-first-and-last-ip-of-a-subnet</link>
		<comments>http://blog.tyang.org/2012/02/09/powershell-script-calculate-first-and-last-ip-of-a-subnet/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 23:29:20 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=983</guid>
		<description><![CDATA[I just wrote this script to calculate the first and last IP of a subnet based on any given IP (within the subnet) and it&#8217;s subnet mask: Syntax: .\Get-NetworkStartEndAddress.ps1 “IP address” “Subnet Mask” Download here: Get-NetworkStartEndAddress.ps1]]></description>
			<content:encoded><![CDATA[<p>I just wrote this script to calculate the first and last IP of a subnet based on any given IP (within the subnet) and it&#8217;s subnet mask:</p>
<p><strong>Syntax:</strong> .\Get-NetworkStartEndAddress.ps1 “IP address” “Subnet Mask”</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/02/Get-NetworkStartEndingAddress.png"><img class="alignnone size-full wp-image-984" title="Get-NetworkStartEndingAddress" src="http://blog.tyang.org/wp-content/uploads/2012/02/Get-NetworkStartEndingAddress.png" alt="" width="661" height="296" /></a></p>
<p>Download here: <a href="http://blog.tyang.org/wp-content/uploads/2012/02/Get-NetworkStartEndAddress.ps1_.txt">Get-NetworkStartEndAddress.ps1</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/02/09/powershell-script-calculate-first-and-last-ip-of-a-subnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SCCM Report: Site Boundaries</title>
		<link>http://blog.tyang.org/2012/02/02/sccm-report-site-boundaries/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sccm-report-site-boundaries</link>
		<comments>http://blog.tyang.org/2012/02/02/sccm-report-site-boundaries/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 22:34:48 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[SCCM]]></category>
		<category><![CDATA[SCCM Reports]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=978</guid>
		<description><![CDATA[I wrote this simple report yesterday to list and search site boundaries: Report Name: SCCM Site Boundaries SQL Query: &#160; Prompts: Name: BoundaryName Prompt Text: Boundary Name Prompt SQL Statement:]]></description>
			<content:encoded><![CDATA[<p>I wrote this simple report yesterday to list and search site boundaries:</p>
<p>Report Name: SCCM Site Boundaries</p>
<p><strong>SQL Query:</strong></p>
<pre class="brush: sql; title: ; notranslate">
SELECT distinct
v_BoundaryInfo.DisplayName AS [Boundary Name],
Case v_BoundaryInfo.BoundaryType
When 0 then 'IP Subnet'
When 1 then 'AD Site'
When 2 then 'IPV6 Prefix'
When 3 then 'IP Range'
End As 'Type',
v_BoundaryInfo.Value AS [Value],
v_BoundaryInfo.SiteCode AS [Site Code]
From v_BoundaryInfo WHERE DisplayName LIKE @BoundaryName
</pre>
<p>&nbsp;</p>
<p><strong>Prompts:</strong></p>
<p>Name: BoundaryName</p>
<p>Prompt Text: Boundary Name</p>
<p>Prompt SQL Statement:</p>
<pre class="brush: sql; title: ; notranslate">
begin
if (@__filterwildcard = '')
Select DisplayName from v_BoundaryInfo order by DisplayName
else
Select DisplayName from v_BoundaryInfo where DisplayName LIKE @__filterwildcard order by DisplayName
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/02/02/sccm-report-site-boundaries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SCCM Health Check Script Updated: Version 3.5</title>
		<link>http://blog.tyang.org/2012/01/31/sccm-health-check-script-updated-version-3-5/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sccm-health-check-script-updated-version-3-5</link>
		<comments>http://blog.tyang.org/2012/01/31/sccm-health-check-script-updated-version-3-5/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 09:55:11 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[SCCM]]></category>
		<category><![CDATA[Health Check]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=973</guid>
		<description><![CDATA[I have just updated the SCCM Health Check Script to from version 3.3 to 3.5 Version 3.4 was finished a while back but I never got time to publish it in this blog. I only emailed 3.4 to few people who contacted me from my blog. Now that I’ve updated it again to 3.5, I [...]]]></description>
			<content:encoded><![CDATA[<p>I have just updated the <a title="SCCM Health Check Script" href="http://blog.tyang.org/2011/03/30/powershell-script-sccm-health-check/">SCCM Health Check Script </a>to from version 3.3 to 3.5</p>
<p>Version 3.4 was finished a while back but I never got time to publish it in this blog. I only emailed 3.4 to few people who contacted me from my blog. Now that I’ve updated it again to 3.5, I thought I’ll just publish version 3.5.</p>
<h2><span style="color: #ff0000;">What’s Changed Since 3.3?</span></h2>
<ol>
<li>Added site system name under &#8216;site systems with issues&#8217; section</li>
<li>Detect site components that are missing heartbeats.</li>
<li>Changed function Validate-DNSRecord to use Win32_ComputerSystem.caption rather than DNSHostname to retrieve computer name as DNSHostName is not available on computers before Windows 2008.</li>
</ol>
<h2><span style="color: #ff0000;">Update Instruction</span></h2>
<p>A new item has been added to the configuration XML (Health-Check.xml):<br />
<span style="color: #ff0000;">   &lt;MaxMissingHeartBeatTolerance&gt;<br />
&lt;Hours&gt;24&lt;/Hours&gt;<br />
&lt;/MaxMissingHeartBeatTolerance&gt;</span></p>
<p>As the name suggest, the script raises any site systems as problematic if it has not sent heartbeat for over the X number of hours that you configured in XML (in my example, it’s 24 hours).</p>
<p>You may keep the old XML that you have already configured for your environment as long as you add the following lines in the Health-Check.XML:</p>
<p>&nbsp;</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image62.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb62.png" alt="image" width="532" height="314" border="0" /></a></p>
<p>You can download version 3.5 <span style="font-size: medium;"><strong><a href="http://blog.tyang.org/wp-content/uploads/2012/01/SCCM-Health-Check-v3.5.zip">HERE</a></strong></span>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/01/31/sccm-health-check-script-updated-version-3-5/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Command Line Parameters for SCOM Command Notification Channel</title>
		<link>http://blog.tyang.org/2012/01/29/command-line-parameters-for-scom-command-notification-channel/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=command-line-parameters-for-scom-command-notification-channel</link>
		<comments>http://blog.tyang.org/2012/01/29/command-line-parameters-for-scom-command-notification-channel/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 06:53:17 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SCOM]]></category>
		<category><![CDATA[Command Notification]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=962</guid>
		<description><![CDATA[Few years ago, I wrote the Enhanced SCOM Alert Notification script and I blogged it here. In all the environments that I implemented this script in command notification channel, there were always some random alerts not been processed. Few months ago, I was working on another PowerShell script to be used in command notification channel [...]]]></description>
			<content:encoded><![CDATA[<p>Few years ago, I wrote the Enhanced SCOM Alert Notification script and I blogged it <a href="http://blog.tyang.org/2010/07/19/enhanced-scom-alerts-notification-emails/">here</a>.</p>
<p>In all the environments that I implemented this script in command notification channel, there were always some random alerts not been processed.</p>
<p>Few months ago, I was working on another PowerShell script to be used in command notification channel to update a custom field when alerts are created. While I was testing it, I found it has exactly the same problem, the subscription randomly skips alerts and left them not processed.</p>
<p>In the end, I found the cause of the problem: the command line parameters are not configured properly! The details can be found in Steve Rachui’s blog article here: <a href="http://blogs.msdn.com/b/steverac/archive/2010/08/17/updating-custom-alert-fields-using-subscriptions-and-powershell.aspx">Updating custom alert fields using subscriptions and powershell</a>. Steve explained in the article:</p>
<blockquote><p>There are several quotation marks in the command line so I’ve listed the text again below in case you want to copy/paste in your environment. Note the highlights above – these are single quotes that go around alert ID as it’s passed to the script. Make sure you include these because if you don’t the alert ID won’t be handled correctly in all cases and the script will not run consistently.</p>
<p>Full path of the command file: <em>c:\windows\system32\windowspowershell\v1.0\powershell.exe<br />
</em><strong>Command line parameters: </strong><em><strong>-Command &#8220;&amp; &#8216;&#8221;C:\alertupdater.ps1&#8243;&#8216;&#8221; &#8216;$Data/Context/DataItem/AlertId$&#8217;<br />
</strong></em>Startup folder for the command line: <em>c:\windows\system32\windowspowershell\v1.0\</em></p></blockquote>
<p>So to fix my problem with my Ehanced SCOM Alert Nofication Script, the command line parameter should be:</p>
<p><strong><span style="color: #ff0000;">-Command &#8220;&amp; &#8216;&#8221;D:\Scripts\SCOMEnhancedEmailNotification.ps1&#8243;&#8216;&#8221; -alertID &#8216;$Data/Context/DataItem/AlertId$&#8217; -Recipients @(&#8216;Tao Yang;Tao.Yang@xxxx.com’,John Smith;John.Smith@xxxx.com‘)</span></strong></p>
<p><strong>I’ve updated the original Enhanced SCOM Alerts Notification EMails blog article to reflect this change.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/01/29/command-line-parameters-for-scom-command-notification-channel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SCOM: Monitoring an Interactive Process and The Recovery Task</title>
		<link>http://blog.tyang.org/2012/01/28/scom-monitoring-an-interactive-process-and-the-recovery-task/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=scom-monitoring-an-interactive-process-and-the-recovery-task</link>
		<comments>http://blog.tyang.org/2012/01/28/scom-monitoring-an-interactive-process-and-the-recovery-task/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 22:37:52 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[SCOM]]></category>
		<category><![CDATA[MP Authoring]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=946</guid>
		<description><![CDATA[Recently I’m working on a management pack for a series of apps for a business unit of my employer. There is a large number of processes that I need to monitor and they run interactively on the console session. Auto Admin Logon is enabled on these servers, when the server starts up, it automatically logged [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I’m working on a management pack for a series of apps for a business unit of my employer. There is a large number of processes that I need to monitor and they run interactively on the console session. Auto Admin Logon is enabled on these servers, when the server starts up, it automatically logged on using the account configured and the the interactive processes are automatically started.</p>
<p>Setting up monitors for these processes is easy. However, I went a step further and created a generic write action module to be used as recovery task that restarts the process interactively on the console session.</p>
<p>There is one pre-requisite for the recovery task: I had to use PsExec to launch the process on console session. PsExec can be downloaded here: <a href="http://technet.microsoft.com/en-us/sysinternals/bb897553">http://technet.microsoft.com/en-us/sysinternals/bb897553</a>. PsExec needs to be copied locally to the computers that are being monitored.</p>
<p>I’ll now use use an example to go through how I setup the monitor, write action module and recovery task for notepad.exe</p>
<p><strong><span style="color: #ff0000;">01.</span></strong> First of all, I created a class and its discovery to target my test machine “Client01”</p>
<p><strong><span style="color: #ff0000;">02.</span></strong> Added “Microsoft.SystemCenter.ProcessMonitoring.Library” as a reference in my MP.</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image40.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb40.png" alt="image" width="481" height="477" border="0" /></a></p>
<p><span style="color: #ff0000;">03.</span> Created a process monitor for notepad.exe</p>
<ul>
<ul>
<li><strong>Monitor Type:</strong> Process Instance Count Monitor Type (from “Microsoft.SystemCenter.ProcessMonitoring.Library”)</li>
<li><strong>Monitor Configuration:</strong></li>
<li></li>
</ul>
</ul>
<table width="600" border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="444">ProcessName</td>
<td valign="top" width="156">notepad.exe</td>
</tr>
<tr>
<td valign="top" width="444">Frequency</td>
<td valign="top" width="156">60</td>
</tr>
<tr>
<td valign="top" width="444">MinInstanceCount</td>
<td valign="top" width="156">1</td>
</tr>
<tr>
<td valign="top" width="444">MaxInstanceCount</td>
<td valign="top" width="156">1</td>
</tr>
<tr>
<td valign="top" width="444">InstanceCountOutOfRangeTimeThresholdInSeconds</td>
<td valign="top" width="156">5</td>
</tr>
</tbody>
</table>
<ul>
<li><span style="color: #ff0000; font-size: small;"><strong>Note:</strong></span> While I was setting up the monitor, I realised the process name is case sensitive. Also, Frequency is in seconds</li>
<li><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image41.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb41.png" alt="image" width="550" height="273" border="0" /></a></li>
<li>This is pretty much the same as using the Process Monitoring template from from the SCOM operations console (under Authoring Pane) – Except I used my own class rather than targeting to a group. Below is from the process monitoring wizard:</li>
<li><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image42.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb42.png" alt="image" width="537" height="395" border="0" /></a></li>
</ul>
<p><strong><span style="color: #ff0000;">04.</span></strong> Now once I import the MP into my SCOM management group, I can verify it is working (from health explorer):</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image43.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb43.png" alt="image" width="580" height="474" border="0" /></a></p>
<p align="left"><strong><span style="color: #ff0000;">05.</span></strong> Because the way this monitor works, it is only healthy when the process count is in between MinInstanceCount and MaxInstanceCount (both set to 1 in this case). So the monitor’s health turns to Errorif there are say 2 instance of notepad running. Therefore I need to run a diagnostic task to determine how many instances are actually running because I only want to run the recovery task when the instance count is less than 1. I created a diagnostic task to run when the monitor’s health is in Error state. This diagnostic has only 1 action module: <strong>“Microsoft.Windows.ScriptPropertyBagProbe”:</strong></p>
<p align="left"><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image44.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb44.png" alt="image" width="544" height="535" border="0" /></a></p>
<ul>
<ul>
<li>
<div align="left"><strong>Module configuration:</strong></div>
</li>
<li>
<table width="600" border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="300">ScriptName</td>
<td valign="top" width="300">CheckProcessDiagnostic.vbs</td>
</tr>
<tr>
<td valign="top" width="300">Arguments</td>
<td valign="top" width="300">notepad.exe</td>
</tr>
<tr>
<td valign="top" width="300">ScriptBody</td>
<td valign="top" width="300">refer to the vbscript below</td>
</tr>
<tr>
<td valign="top" width="300">TimeoutSeconds</td>
<td valign="top" width="300">60</td>
</tr>
</tbody>
</table>
</li>
<li>
<div align="left">Here’s the script:</div>
</li>
</ul>
</ul>
<pre class="brush: vb; title: ; notranslate">
'==========================================
' AUTHOR:            Tao Yang
' Script Name:        CheckProcessDiagnostic.vbs
' DATE:                27/01/2012
' Version:            1.0
' COMMENT:            - Script to check process state.
'                    - Used for OpsMgr Management Pack diagnostic tasks.
'==========================================
ProcessName = WScript.Arguments.Item(0)
Set oAPI = CreateObject(&quot;MOM.ScriptAPI&quot;)
Set oBag = oAPI.CreatePropertyBag()
WMIQuery = &quot;Select * From Win32_process WHERE name = '&quot; + ProcessName + &quot;'&quot;
Set objWMIService = GetObject(&quot;winmgmts:\\.\root\cimv2&quot;)
Set colProcesses = objWMIService.ExecQuery (WMIQuery)
Call oBag.AddValue(&quot;ProcessName&quot;,ProcessName)
If colProcesses.count &amp;lt; 1 Then
Call oBag.AddValue(&quot;Result&quot;,&quot;Positive&quot;)
Else
Call oBag.AddValue(&quot;Result&quot;,&quot;Negative&quot;)
End If
oAPI.Return(oBag)
</pre>
<ul>
<li>This script returns a property bag variable“Result”. The value of “Result” is “Positive” if there is less than 1 instance of notepad.exe running. otherwise, the value is “Negative”. I will use the the value of “Result” to determine whether to run the recovery task or not by using a condition detection module in recovery task later.</li>
</ul>
<p><strong><span style="color: #ff0000;">06.</span></strong> Create a Write Actions module for the recovery task. I’m creating a separate module for this so I can use it in recovery tasks of multiple monitors.</p>
<ul>
<ul>
<li><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image45.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb45.png" alt="image" width="522" height="514" border="0" /></a></li>
<li>Member Module: <strong>“Microsoft.Windows.PowerShellWriteAction”</strong></li>
<li><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image46.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb46.png" alt="image" width="545" height="536" border="0" /></a></li>
<li><strong>Module Configuration:</strong></li>
<li><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image47.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb47.png" alt="image" width="719" height="683" border="0" /></a></li>
<li>While editing this module, Add below secion between &lt;/ScriptBody&gt; and &lt;/Configuration&gt;:</li>
</ul>
</ul>
<p><span style="color: #ff0000;">&lt;Parameters&gt;<br />
&lt;Parameter&gt;<br />
&lt;Name&gt;PsExecPath&lt;/Name&gt;<br />
&lt;Value&gt;$Config/PsExecPath$&lt;/Value&gt;<br />
&lt;/Parameter&gt;<br />
&lt;Parameter&gt;<br />
&lt;Name&gt;PathToExe&lt;/Name&gt;<br />
&lt;Value&gt;$Config/PathToExe$&lt;/Value&gt;<br />
&lt;/Parameter&gt;<br />
&lt;Parameter&gt;<br />
&lt;Name&gt;Context&lt;/Name&gt;<br />
&lt;Value&gt;$Config/Context$&lt;/Value&gt;<br />
&lt;/Parameter&gt;<br />
&lt;Parameter&gt;<br />
&lt;Name&gt;Arguments&lt;/Name&gt;<br />
&lt;Value&gt;$Config/Arguments$&lt;/Value&gt;<br />
&lt;/Parameter&gt;<br />
&lt;/Parameters&gt;<br />
&lt;TimeoutSeconds&gt;$Config/TimeoutSeconds$&lt;/TimeoutSeconds&gt;</span></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image48.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb48.png" alt="image" width="545" height="385" border="0" /></a><br />
Place the PowerShell script below between &lt;ScriptBody&gt;&lt;/ScriptBody&gt; section:</p>
<pre class="brush: powershell; title: ; notranslate">
#=================================================
# AUTHOR:  Tao Yang
# DATE:    16/01/2012
# Version: 1.0
# COMMENT: Start a exe on console session under LocalSystem Context
#=================================================

param([string]$PsExecPath, [string]$PathToExe, [string]$Context, [string]$Arguments)
# $Context should have only 2 possible values: &quot;System&quot; or &quot;User&quot;. &quot;User&quot; needs Auto Admin Logon Enabled
Function Get-ConsoleSessionInfo
{
$results = Query Session
$ConsoleSession = $results | select-string &quot;console\s+(\w+)\s+(\d+)\s+(\w+)&quot;
if ($ConsoleSession)
{
$UserName = $ConsoleSession.Matches[0].groups[1].value
$SessionID = $ConsoleSession.Matches[0].groups[2].value
$State = $ConsoleSession.Matches[0].groups[3].value
$objConsoleSession = New-Object psobject
Add-Member -InputObject $objConsoleSession -Name &quot;UserName&quot; -Value $UserName -MemberType NoteProperty
Add-Member -InputObject $objConsoleSession -Name &quot;SessionID&quot; -Value $SessionID -MemberType NoteProperty
Add-Member -InputObject $objConsoleSession -Name &quot;State&quot; -Value $State -MemberType NoteProperty
} else { $objConsoleSession = $null }
Return $objConsoleSession
}

$Mode = $null
#Determine UserID
If ($Context -ieq &quot;User&quot;)
{
$strUserName = $null
$DefaultPassword = $null
#detect if auto admin is enabled, if so, retrieve username and password from registry
$WinlogonRegKey = get-itemproperty &quot;HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\&quot;
If ($WinlogonRegKey.AutoAdminLogon = &quot;1&quot;)
{
$DefaultUserName = $WinlogonRegKey.DefaultUserName
$DefaultDomainName = $WinlogonRegKey.DefaultDomainName
$DefaultPassword = $WinlogonRegKey.DefaultPassword
$strUserName = &quot;$DefaultDomainName`\$DefaultUserName&quot;
}

If ($strUserName -and $DefaultPassword)
{
$Mode = &quot;User&quot;
} else {
Write-Error &quot;Owner variable set to `&quot;User`&quot; but Auto Admin Logon is not configured!&quot;
}
} elseif ($Context -ieq &quot;System&quot;) {
$Mode = &quot;System&quot;
} else {
Write-Error &quot;Incorrect Owner variable. it can only be `&quot;User`&quot; or `&quot;System`&quot;&quot;
}

#$thisScript = Split-Path $myInvocation.MyCommand.Path -Leaf
#$scriptRoot = Split-Path(Resolve-Path $myInvocation.MyCommand.Path)
#$PsExecPath = Join-Path $scriptRoot &quot;PsExec.exe&quot;
If (!(Test-Path $PsExecPath))
{
Write-Error &quot;Unable to locate PsExec.exe in $scriptRoot. Please make sure it is located in this directory!&quot;
} else {
#Get Console Session ID
$ConsoleSessionID = (Get-ConsoleSessionInfo).SessionID
if ($ConsoleSessionID)
{
If ($Mode -eq &quot;User&quot;)
{
$strCmd = &quot;$PsExecPath -accepteula -i $ConsoleSessionID -d -u $strUsername -p $DefaultPassword $PathToExe $arguments&quot;
Write-Host &quot;Executing $strCmd`...&quot;
Invoke-Expression $strCmd
} elseif ($Mode -eq &quot;System&quot;) {
$strCmd = &quot;$PsExecPath -accepteula -i $ConsoleSessionID -d -s $PathToExe $arguments&quot;
#run app under LOCALSYSTEM context
Write-Host &quot;Executing $strCmd`...&quot;
Invoke-Expression $strCmd
}
} else {
Write-Error &quot;No one is currently logged on to the console session at the moment.&quot;
}
}
</pre>
<p><span style="color: #ff0000;"><strong>Note:</strong></span>this PowerShell script uses command “query session” to detect the session ID of the console session.</p>
<p><span style="color: #ff0000;"><strong>Note:</strong></span> When you save the configuration of this module, please <strong>ignore</strong> this error:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image49.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb49.png" alt="image" width="445" height="206" border="0" /></a></p>
<p>Add the following item under Configuration Schema tab:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image50.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb50.png" alt="image" width="545" height="547" border="0" /></a></p>
<p><strong><span style="color: #ff0000;">Note: </span></strong>Make sure “TimeoutSeconds” type is set to “Integer” and others are set to “String”</p>
<p>I also defined “TimeoutSeconds” as an overridable paramter:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image51.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb51.png" alt="image" width="545" height="234" border="0" /></a></p>
<p>Finally, set the Accessibility to Public (so it can be used in other management pack once this management pack is sealed&#8221;):</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image52.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb52.png" alt="image" width="545" height="175" border="0" /></a></p>
<p><strong><span style="color: #ff0000;">07.</span></strong> Create a recovery task to run after Diagnostic Task that I created from the step 5.</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image53.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb53.png" alt="image" width="479" height="475" border="0" /></a></p>
<ul>
<li>This recovery task has 2 modules: a condition detection module (System.ExpressionFilter) and an Actions module (From the Write Actions module I created from Step 6)</li>
</ul>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image54.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb54.png" alt="image" width="525" height="523" border="0" /></a></p>
<ul>
<ul>
<li><strong>Condition Detection Module (System.ExpressionFilter):</strong></li>
<li><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image55.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb55.png" alt="image" width="593" height="562" border="0" /></a></li>
<li>Click Edit and add below:</li>
</ul>
</ul>
<p><span style="color: #ff0000;">&lt;Expression&gt;<br />
&lt;SimpleExpression&gt;<br />
&lt;ValueExpression&gt;<br />
&lt;XPathQuery Type=&#8221;String&#8221;&gt;Diagnostic/DataItem/Property[@Name='Result']&lt;/XPathQuery&gt;<br />
&lt;/ValueExpression&gt;<br />
&lt;Operator&gt;Equal&lt;/Operator&gt;<br />
&lt;ValueExpression&gt;<br />
&lt;Value Type=&#8221;String&#8221;&gt;Positive&lt;/Value&gt;<br />
&lt;/ValueExpression&gt;<br />
&lt;/SimpleExpression&gt;<br />
&lt;/Expression&gt;</span></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image56.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb56.png" alt="image" width="545" height="184" border="0" /></a></p>
<p><strong>Actions Module (Module Type from the write action module created in Step 6)</strong></p>
<table width="600" border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="143">PsExecPath</td>
<td valign="top" width="457">Path to PsExec.exe on the target computer</td>
</tr>
<tr>
<td valign="top" width="143">PathToExe</td>
<td valign="top" width="457">The executable that you want PsExec to run</td>
</tr>
<tr>
<td valign="top" width="143">Context</td>
<td valign="top" width="457">2 Possible values: “User” or “System”</td>
</tr>
<tr>
<td valign="top" width="143">Argument</td>
<td valign="top" width="457">arguments for the executable that PsExec is executing</td>
</tr>
<tr>
<td valign="top" width="143">TimeoutSeconds</td>
<td valign="top" width="457"></td>
</tr>
</tbody>
</table>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image57.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb57.png" alt="image" width="545" height="331" border="0" /></a></p>
<p><strong><span style="color: #ff0000;">Note:</span></strong> Regarding to the Context variable, I designed the script to launch PsExec to execute the executable either under LOCALSYSTEM (  with –s  operator in PsExec) or under the user that’s configured for Auto Admin Logon (with –u &lt;username&gt; and –p &lt;password&gt; operators in PsExec). Because when Auto Admin Logon is enabled, the default username and password is stored in the registry key (<strong>HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon</strong>). If “Context” is set to “User”, the script reads the username and password from registry and pass them into PsExec. So, if Auto Admin Logon is not configured, the script won’t work if “Context” is set to “User”</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image58.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb58.png" alt="image" width="545" height="259" border="0" /></a></p>
<p><strong><span style="color: #ff0000;">Note:</span></strong> In this example, the recovery task simply launch notepad.exe on the console session. I can also tell notepad to open a txt file if I add the path of the txt file to “Arguments”.</p>
<p><strong><span style="color: #ff0000;">Note:</span></strong> This recovery task will error out if no one has logged on to the console session of the target computer.</p>
<p>Now, everything is setup, time to put it to test.</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image59.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb59.png" alt="image" width="545" height="482" border="0" /></a></p>
<p>From screen capture below, I can see the monitor’s health became Error at 10:44pm 27/01/2012. After the Diagnostic task determined there is no notepad.exe running, the recovery task kicks in, at 10:45pm, it launched notepad.exe on console session (session ID 2). The PID of notepad.exe is 4000.</p>
<p>Now, when I go to the target computer, notepad is launched on the console session and I can easily get the details of notepad.exe process:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/notepad.png"><img class="alignleft  wp-image-956" title="notepad" src="http://blog.tyang.org/wp-content/uploads/2012/01/notepad-300x252.png" alt="" width="498" height="335" /></a></p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image60.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb60.png" alt="image" width="545" height="464" border="0" /></a></p>
<p>You can see from above screen capture, notepad.exe was started at the same time when the recovery task ran, the session ID is 2, Owner is the account configured for Auto Admin Logon and process ID is same as the output from PsExec. Therefore, this instance of notepad.exe is the one started by the recovery task!</p>
<p>I’ve attached the 2 scripts used in Diagnostic and recovery tasks below. as well as my sample unsealed MP.</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/Custom.Interactive.Process.Monitoring.zip">Download From Here</a></p>
<p>Please feel free to contact me if you have any questions or suggestions.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/01/28/scom-monitoring-an-interactive-process-and-the-recovery-task/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SCOM: Process Performance Collection Rule for Services</title>
		<link>http://blog.tyang.org/2012/01/27/scom-process-performance-collection-rule-for-services/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=scom-process-performance-collection-rule-for-services</link>
		<comments>http://blog.tyang.org/2012/01/27/scom-process-performance-collection-rule-for-services/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 02:28:08 +0000</pubDate>
		<dc:creator>Tao Yang</dc:creator>
				<category><![CDATA[SCOM]]></category>
		<category><![CDATA[MP Authoring]]></category>
		<category><![CDATA[PerfMon]]></category>

		<guid isPermaLink="false">http://blog.tyang.org/?p=888</guid>
		<description><![CDATA[Setting up Performance Collection rules for a particular process is pretty straightforward in SCOM. However, the it has it’s limitations. Process performance collections rules are straightforward to setup, as long as there is ONLY ONE instance of the particular process running on the computers that your rule is targeting. Also, each rule can only collect [...]]]></description>
			<content:encoded><![CDATA[<p>Setting up Performance Collection rules for a particular process is pretty straightforward in SCOM. However, the it has it’s limitations.</p>
<p>Process performance collections rules are straightforward to setup, as long as there is ONLY ONE instance of the particular process running on the computers that your rule is targeting. Also, each rule can only collect ONE performance counter.</p>
<p>The problem with that is, if I need to collect performance counters for a particular service, i.e. Server Service (lanmanserver) or a particular SQL server instance (when there are multiple SQL instances running on the same server) , I will not be able to do so using the default performance collection module “System.Performance.OptimizedDataProvider” because server service runs under the generic service host svchost.exe. Typically, there are many instances of svchost.exe running for various services:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image31.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb31.png" alt="image" width="580" height="756" border="0" /></a></p>
<p>According to above screen capture, there are 10 instances of svchost.exe running on my computer. And when selecting performance counter in SCOM consoles, there are 10 instances of svchost:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image32.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb32.png" alt="image" width="537" height="428" border="0" /></a></p>
<p>It’s the same if I simply run perfmon on the computer: there are 10 instances of svchost:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image33.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb33.png" alt="image" width="580" height="426" border="0" /></a></p>
<p>There’s actually a blog article on TechNet explaining this issue with perfmon: <a href="http://blogs.technet.com/b/askperf/archive/2010/03/30/perfmon-identifying-processes-by-pid-instead-of-instance.aspx">Perfmon: Identifying processes by PID instead of instance</a></p>
<p>So, there is a workaround for perfmon, but it doesn’t really help me with my performance collection rule in SCOM.</p>
<p>To overcome this issue, I had to create some customized modules to collect the counters that I’m interested in via WMI. I’ll now explain what I’ve done to achieve the goal.</p>
<p>1. I firstly created a probe action module to run a vbscript to collect ALL the counters I’m interested in via WMI. In the script:</p>
<ol>
<li>takes the service name and computer name from the input parameter, get the PID for the service from <strong>win32_service</strong> class (note, I had to pass computer name to the script so it can connect to remote computer’s WMI namespace, this is required for agentless monitoring)</li>
<li>retrieve the values of the performance counters from <strong>Win32_PerfFormattedData_PerfProc_Process</strong> class using query <strong>&#8220;Select * from Win32_PerfFormattedData_PerfProc_Process Where IDProcess = ProcessID&#8221;</strong> (ProcessID was retrieved from step 1)</li>
<li>For each performance counter, create a property bag and add the property bag to MOM.ScriptAPI object</li>
<li>Return all property bags.</li>
</ol>
<p>2. Create a Data Source module which contains 3 modules and the modules are executed on the following order:</p>
<ol>
<li>System.SimpleScheduler (runs according to a schedule)</li>
<li>Probe module created from step 1 (retrieve performance counters and return then via property bag)</li>
<li>System.Performance.DataGenericMapper (Map the property bag values to performance data)</li>
</ol>
<p>Now that I’ve created all the required modules, I can then create a SINGLE rule to collect all different counters that I defined in the probe action module. To do so:</p>
<p>1. In Authoring console, create a Custom Rule:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image34.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb34.png" alt="image" width="311" height="236" border="0" /></a></p>
<p>2. Give the rule a name and choose the target:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image35.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb35.png" alt="image" width="580" height="578" border="0" /></a></p>
<p>3. Add the data source module I previously created and configure the variables (service name is the actual service name, <span style="color: #ff0000;"><strong>NOT</strong></span> service display name):</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image36.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb36.png" alt="image" width="580" height="534" border="0" /></a></p>
<p><strong><span style="color: #ff0000; font-size: medium;">Note:</span></strong> The <strong>Computername</strong> variable from above example is “$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$”, this is correct because I’m targeting the rule to Windows Computer. You will have to change it if you are targeting other classes. The best way is to use the prompt and choose the host’s principal name. Below is an example if I target the rule to Windows Operating System:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image37.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb37.png" alt="image" width="580" height="525" border="0" /></a></p>
<p>4. Add 2 Actions module (don’t need to configure them):</p>
<ol>
<li>Microsoft.SystemCenter.CollectionPerformanceData (WriteToDB)</li>
<li>Microsoft.SystemCenter.DataWarehouse.PublishPerformanceData (WriteToDW)</li>
</ol>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image38.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb38.png" alt="image" width="580" height="455" border="0" /></a></p>
<p><strong><span style="color: #ff0000; font-size: medium;">Note:</span></strong> The 2nd action module WriteToDW is from Microsoft.SystemCenter.DataWarehouse.Library. you will have to add this library as a reference of your management pack.</p>
<p>Now, the rule is created, you can create a performance view for the rule and make sure it is collecting data:</p>
<p><a href="http://blog.tyang.org/wp-content/uploads/2012/01/image39.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.tyang.org/wp-content/uploads/2012/01/image_thumb39.png" alt="image" width="580" height="479" border="0" /></a></p>
<p>Below is the VBScript I’ve used in probe action module:</p>
<pre class="brush: vb; title: ; notranslate">
'=========================================================================
' AUTHOR:             Tao Yang
' Script Name:        ProcessPerfMonData.vbs
' DATE:               23/01/2012
' Version:            1.0
' COMMENT:            Script to collect perfmon data for specific service
'=========================================================================
Option Explicit
SetLocale(&quot;en-us&quot;)
Dim ServiceName, objWMIService,colService, objService, ComputerName
Dim ProcessID, ProcessName, colProcess, objProcess, colPerfData, objPerfData
Dim ElapsedTime, PercentProcessorTime, PercentUserTime, ThreadCount, PageFaultsPersec, IOReadBytesPersec, IOWriteBytesPersec
Dim oAPI, oBag, oInst
ServiceName = WScript.Arguments.Item(0)
ComputerName = Wscript.Arguments.Item(1)
Set oAPI = CreateObject(&quot;MOM.ScriptAPI&quot;)

Set objWMIService = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; &amp; ComputerName &amp;&quot;\root\cimv2&quot;)
Set colService = objWMIService.ExecQuery(&quot;Select * from Win32_Service Where Name = '&quot; + ServiceName + &quot;'&quot;)

For Each objService in colService
ProcessID = objService.ProcessID
Next

If ProcessID &lt;&gt; 0 THEN
Set colProcess = objWMIService.ExecQuery(&quot;Select * from Win32_Process Where ProcessID = &quot; &amp; ProcessID)
For Each objProcess in colProcess
ProcessName = objProcess.Name
Next
Set colPerfData = objWMIService.ExecQuery(&quot;Select * from Win32_PerfFormattedData_PerfProc_Process Where IDProcess = &quot; &amp; ProcessID)
For Each objPerfData in colPerfData
ElapsedTime = objPerfData.ElapsedTime
PercentProcessorTime = objPerfData.PercentProcessorTime
PercentUserTime = objPerfData.PercentUserTime
ThreadCount = objPerfData.ThreadCount
PageFaultsPersec = objPerfData.PageFaultsPersec
IOReadBytesPersec = objPerfData.IOReadBytesPersec
IOWriteBytesPersec = objPerfData.IOWriteBytesPersec
Next
'Elapsed Time
Set oBag = oAPI.CreatePropertyBag()
oBag.AddValue &quot;Object&quot;, &quot;Process&quot;
oBag.AddValue &quot;Instance&quot;, ServiceName
oBag.AddValue &quot;Counter&quot;, &quot;Elapsed Time&quot;
oBag.AddValue &quot;Value&quot;, ElapsedTime
oAPI.AddItem(oBag)

'Percent Processor Time
Set oBag = oAPI.CreatePropertyBag()
oBag.AddValue &quot;Object&quot;, &quot;Process&quot;
oBag.AddValue &quot;Instance&quot;, ServiceName
oBag.AddValue &quot;Counter&quot;, &quot;% Processor Time&quot;
oBag.AddValue &quot;Value&quot;, PercentProcessorTime
oAPI.AddItem(oBag)

'Percent User Time
Set oBag = oAPI.CreatePropertyBag()
oBag.AddValue &quot;Object&quot;, &quot;Process&quot;
oBag.AddValue &quot;Instance&quot;, ServiceName
oBag.AddValue &quot;Counter&quot;, &quot;% User Time&quot;
oBag.AddValue &quot;Value&quot;, PercentUserTime
oAPI.AddItem(oBag)

'Thread Count
Set oBag = oAPI.CreatePropertyBag()
oBag.AddValue &quot;Object&quot;, &quot;Process&quot;
oBag.AddValue &quot;Instance&quot;, ServiceName
oBag.AddValue &quot;Counter&quot;, &quot;Thread Count&quot;
oBag.AddValue &quot;Value&quot;, ThreadCount
oAPI.AddItem(oBag)

'Page Faults/Sec
Set oBag = oAPI.CreatePropertyBag()
oBag.AddValue &quot;Object&quot;, &quot;Process&quot;
oBag.AddValue &quot;Instance&quot;, ServiceName
oBag.AddValue &quot;Counter&quot;, &quot;Page Faults/sec&quot;
oBag.AddValue &quot;Value&quot;, PageFaultsPersec
oAPI.AddItem(oBag)

'IO Read Bytes/sec
Set oBag = oAPI.CreatePropertyBag()
oBag.AddValue &quot;Object&quot;, &quot;Process&quot;
oBag.AddValue &quot;Instance&quot;, ServiceName
oBag.AddValue &quot;Counter&quot;, &quot;IO Read Bytes/sec&quot;
oBag.AddValue &quot;Value&quot;, IOReadBytesPersec
oAPI.AddItem(oBag)

'IO Write Bytes/sec
Set oBag = oAPI.CreatePropertyBag()
oBag.AddValue &quot;Object&quot;, &quot;Process&quot;
oBag.AddValue &quot;Instance&quot;, ServiceName
oBag.AddValue &quot;Counter&quot;, &quot;IO Write Bytes/sec&quot;
oBag.AddValue &quot;Value&quot;, IOWriteBytesPersec
oAPI.AddItem(oBag)
ELSE
'Return an empty property bag
Set oBag = oAPI.CreatePropertyBag()
oAPI.AddItem(oBag)
END IF
oAPI.ReturnItems
</pre>
<p>As you can see, I’m collecting the following 7 counters in the script:</p>
<ol>
<li>Elapsed Time</li>
<li>% Processor Time</li>
<li>% User Time</li>
<li>Thread Count</li>
<li>Page Faults/sec</li>
<li>IO Read Bytes/sec</li>
<li>IO Write Bytes/sec</li>
</ol>
<p>You will need to modify the script if you are collecting different counters. for details of the counters you can collect, please refer to Win32_PerfFormattedData_PerfProc_Process class documentation here at MSDN: <a title="http://msdn.microsoft.com/en-us/library/windows/desktop/aa394277(v=vs.85).aspx" href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa394277(v=vs.85).aspx">http://msdn.microsoft.com/en-us/library/windows/desktop/aa394277(v=vs.85).aspx</a></p>
<p>I’ve attached the script and the sample unsealed management pack at the bottom of this article. You can modify or recreate your own based on the samples. don’t forget to seal the management pack if you want to use the modules in other MPs.</p>
<p>VBScript: <a href="http://blog.tyang.org/wp-content/uploads/2012/01/ProcessPerfMonData.txt">ProcessPerfMonData.txt</a></p>
<p>Unsealed MP: <a href="http://blog.tyang.org/wp-content/uploads/2012/01/TYANG.Custom.Performance.Monitoring.zip">TYANG.Custom.Performance.Monitoring.xml</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tyang.org/2012/01/27/scom-process-performance-collection-rule-for-services/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

