<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Otto Helweg - Management Matters</title><link>http://blogs.technet.com/b/otto/</link><description>Management, monitoring, automation, and instrumentation topics for the IT-Pro.</description><dc:language>en-US</dc:language><generator>Telligent Community 5.6.583.17018 (Build: 5.6.583.17018)</generator><item><title>Trigger a PowerShell Script from a Windows Event</title><link>http://blogs.technet.com/b/otto/archive/2011/08/24/trigger-a-powershell-script-from-a-windows-event.aspx</link><pubDate>Wed, 24 Aug 2011 20:53:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3449012</guid><dc:creator>ottoh1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/otto/rsscomments.aspx?WeblogPostID=3449012</wfw:commentRss><comments>http://blogs.technet.com/b/otto/archive/2011/08/24/trigger-a-powershell-script-from-a-windows-event.aspx#comments</comments><description>&lt;p&gt;&lt;em&gt;Note: Portions of this blog are taken from an old blog post titled &amp;ldquo;Reference the Event That Triggered Your Task&amp;rdquo;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This example will demonstrate both how to trigger (launch) a PowerShell script from a specific Windows Event, AND pass parameters to the PowerShell script from the Windows Event that triggered the script. For the purpose of this example, a test event will be generated using the built-in EventCreate command-line utility.&lt;/p&gt;
&lt;p&gt;Background: The scenario behind this example was a need to clean up a file-share after a specific Windows Event occurred. A specific Windows Event was logged upon the success of a file watermarking process. The event used in this example loosely follows the original event format.&lt;/p&gt;
&lt;p&gt;The following steps will be demonstrated:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Manually create the trigger event.&lt;/li&gt;
&lt;li&gt;Use Event Viewer to create an event triggered task from the above event.&lt;/li&gt;
&lt;li&gt;Modify the task to expose event details to the downstream script.&lt;/li&gt;
&lt;li&gt;Implement the PowerShell script to be triggered.&lt;/li&gt;
&lt;li&gt;Verify the setup.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Step 1: Create the trigger event using EventCreate (it&amp;rsquo;s easier to go this route to generate a Scheduled Task for modification rather than trying to create one from scratch).&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;C:\&amp;gt;eventcreate /T INFORMATION /SO SomeApplication /ID 1000 /L APPLICATION /D "&amp;lt;Params&amp;gt;&amp;lt;Timestamp&amp;gt;2011-08-29T21:24:03Z&amp;lt;/Timestamp&amp;gt;&amp;lt;InputFile&amp;gt;C:\temp\Some Test File.txt&amp;lt;/InputFile&amp;gt;&amp;lt;Result&amp;gt;Success&amp;lt;/Result&amp;gt;&amp;lt;/Params&amp;gt;"&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 2: Use the Event Viewer &amp;ldquo;Attach Task to This Event&amp;hellip;&amp;rdquo; feature to create the task.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Launch "Event Viewer" and find the event you created in Step 1. It should be located toward the top of the "Windows Logs\Application" Log. Once found, right-click on the event and select "Attach Task to This Event..." then use the defaults for the first couple screens of the wizard.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-55-30/6557.Trigger_2D00_EventViewer.jpg"&gt;&lt;img border="0" alt="" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-55-30/6557.Trigger_2D00_EventViewer.jpg" /&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Create a task to &amp;ldquo;Start a Program&amp;rdquo; with the following parameters:&lt;/p&gt;
&lt;p&gt;Program/script: &lt;span style="font-family: courier new,courier; background-color: #ffff00;"&gt;PowerShell.exe&lt;/span&gt;&lt;br /&gt;Add arguments: &lt;span style="font-family: courier new,courier; background-color: #ffff00;"&gt;.\TriggerScript.ps1 -eventRecordID $(eventRecordID) -eventChannel $(eventChannel)&lt;/span&gt;&lt;br /&gt;Start in (you might need to create this directory or alter the steps to use a directory of your choice): &lt;span style="font-family: courier new,courier; background-color: #ffff00;"&gt;c:\temp&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: courier new,courier;"&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-55-30/1351.Trigger_2D00_Task.jpg"&gt;&lt;img border="0" alt="" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-55-30/1351.Trigger_2D00_Task.jpg" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 3: Modify the task to expose details about the trigger event and pass them to the PowerShell script&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;From within Task Scheduler, export the newly created task (as an XML file). Right-click on the task "Application_SomeApplication_1000" in the "Event Viewer Tasks" folder, and select "Export...".&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-55-30/8255.Trigger_2D00_Task_2D00_Export.jpg"&gt;&lt;img border="0" alt="" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-55-30/8255.Trigger_2D00_Task_2D00_Export.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Use Notepad (or your text editor of choice - keep in mind the text editor must honor unicode which notepad does) to add the Event parameters you which to pass along to your task. The event parameters below are the most useful for event identification. Notice the entire node &amp;lt;ValueQueries&amp;gt; and its children need to be added to the EventTrigger branch.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ValueQueries&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value name="eventChannel"&amp;gt;Event/System/Channel&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value name="eventRecordID"&amp;gt;Event/System/EventRecordID&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value name="eventSeverity"&amp;gt;Event/System/Level&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ValueQueries&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;See below:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-55-30/7142.Task_2D00_Modification.jpg"&gt;&lt;img border="0" alt="" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-55-30/7142.Task_2D00_Modification.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;From an Elevated Command Prompt, execute the following commands to delete the Trigger Task and recreate it with the newly modified exported Trigger Task (I don't believe there's a way to modify an existing task using an updated XML file).&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;C:\&amp;gt;schtasks /delete /TN "Event Viewer Tasks\Application_SomeApplication_1000"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;C:\&amp;gt;schtasks /create /TN "Event Viewer Tasks\Application_SomeApplication_1000" /XML Application_&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;SomeApplication_1000.xml&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 4: Implement the PowerShell script to be triggered by creating a script called &amp;ldquo;TriggerScript.ps1&amp;rdquo; below&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note: The script below is passed basic information about the event that triggered it. The script then queries the Windows Event Log to get more details about the event (the event payload). For this example, XML is used in the payload to separate the parameters, but any text can be passed as long as the script knows how to parse it. In addition, the &amp;ldquo;eventRecordID&amp;rdquo; that&amp;rsquo;s passed to the script should not be confused with the eventID of the event. The eventRecordID is a sequential number assigned to all events as they are logged to a specific channel. In addition, eventRecordIDs are only unique for a specific Channel (Log).&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;# Script Name: TriggerScript.ps1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;# Usage Example (use a valid ID found via Event Viewer XML view of an event): powershell .\TriggerScript.ps1 -eventRecordID 1 -eventChannel Application&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;# Create a fake event or testing with the following command (from an elevated command prompt):&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;#&amp;nbsp;&amp;nbsp; eventcreate /T INFORMATION /SO SomeApplication /ID 1000 /L APPLICATION /D "&amp;lt;Params&amp;gt;&amp;lt;Timestamp&amp;gt;2011-08-29T21:24:03Z&amp;lt;/Timestamp&amp;gt;&amp;lt;InputFile&amp;gt;C:\temp\Some Test File.txt&amp;lt;/InputFile&amp;gt;&amp;lt;Result&amp;gt;Success&amp;lt;/Result&amp;gt;&amp;lt;/Params&amp;gt;"&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;# Collects all named paramters (all others end up in $Args)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;param($eventRecordID,$eventChannel)&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;$event = get-winevent -LogName $eventChannel -FilterXPath "&amp;lt;QueryList&amp;gt;&amp;lt;Query Id='0' Path='$eventChannel'&amp;gt;&amp;lt;Select Path='$eventChannel'&amp;gt;*[System[(EventRecordID=$eventRecordID)]]&amp;lt;/Select&amp;gt;&amp;lt;/Query&amp;gt;&amp;lt;/QueryList&amp;gt;"&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;[xml]$eventParams = $event.Message&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;if ($eventParams.Params.TimeStamp) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [datetime]$eventTimestamp = $eventParams.Params.TimeStamp&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $eventFile = $eventParams.Params.InputFile&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $popupObject = new-object -comobject wscript.shell&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $popupObject.popup("RecordID: " + $eventRecordID + ", Channel: " + $eventChannel + ", Event Timestamp: " + $eventTimestamp + ", File: " + $eventFile)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note: Besides executing a script, a task can display a popup directly or send an email. An email can be useful for catching infrequent events on your system or in your environment. And a task can be deployed via Group Policy Preferences.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 5: Verify the setup by generating another trigger event as in Step 1&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;C:\&amp;gt;eventcreate /T INFORMATION /SO SomeApplication /ID 1000 /L APPLICATION /D "&amp;lt;Params&amp;gt;&amp;lt;Timestamp&amp;gt;2011-08-29T21:24:03Z&amp;lt;/Timestamp&amp;gt;&amp;lt;InputFile&amp;gt;C:\temp\Some Test File.txt&amp;lt;/InputFile&amp;gt;&amp;lt;Result&amp;gt;Success&amp;lt;/Result&amp;gt;&amp;lt;/Params&amp;gt;"&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;You should see the following Popup window appear (it might be hidden behind other Windows):&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-55-30/5187.Trigger_2D00_Popup.jpg"&gt;&lt;img border="0" alt="" src="http://blogs.technet.com/resized-image.ashx/__size/450x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-55-30/5187.Trigger_2D00_Popup.jpg" /&gt;&lt;/a&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-55-30/2425.Trigger_2D00_Popup.jpg"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Didn&amp;rsquo;t work? Try the following:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Check for the trigger event in Event Viewer (you might need to &amp;ldquo;refresh&amp;rdquo; you view of a log w/F5).&lt;/li&gt;
&lt;li&gt;Manually run the script with real parameters and check for errors (see script comments for usage examples). Since this script is not &amp;ldquo;signed&amp;rdquo;, PowerShell will need to be configured to run an unsigned script (PS&amp;gt; get-help about_Execution_Policies).&lt;/li&gt;
&lt;li&gt;Verify that the task is actually in the Task Scheduler in the folder &amp;ldquo;Event Viewer Tasks&amp;rdquo; and view its &amp;ldquo;History&amp;rdquo;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3449012" width="1" height="1"&gt;</description></item><item><title>Quick and Dirty Reset of a Hyper-V VM with PowerShell</title><link>http://blogs.technet.com/b/otto/archive/2011/08/22/quick-and-dirty-reset-of-a-hyper-v-vm-with-powershell.aspx</link><pubDate>Mon, 22 Aug 2011 19:32:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3448502</guid><dc:creator>ottoh1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/otto/rsscomments.aspx?WeblogPostID=3448502</wfw:commentRss><comments>http://blogs.technet.com/b/otto/archive/2011/08/22/quick-and-dirty-reset-of-a-hyper-v-vm-with-powershell.aspx#comments</comments><description>&lt;p&gt;&lt;em&gt;Note: Remember, this is a &amp;ldquo;Quick and Dirty&amp;rdquo; solution. In fact, because credentials are hard-coded in the script, it is &amp;ldquo;Quick and Filthy&amp;rdquo;. But that tends to be the nature of IT-Pro quick fixes, and I found it useful for a particular scenario. Just remember, this is merely being shown as an example and not a best practice.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Background: I had a problematic VM that would freeze over a period of time which required a &amp;ldquo;Hard Reset&amp;rdquo; to make it functional again. I wanted a way to reset the VM remotely, rather than from the console of the Hyper-V parent.&lt;/p&gt;
&lt;p&gt;The following steps will be taken to perform a hard reset on a VM:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;List (enumerate) the virtual machines on a Hyper-V parent and identify the VM to reset by capturing its &amp;ldquo;Name&amp;rdquo; (GUID).&lt;/li&gt;
&lt;li&gt;Build a credential object that allows the execution of the RequestStateChange method (typically Administrator credentials are required).&lt;/li&gt;
&lt;li&gt;Execute the RequestStateChange method&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;List (Enumerate) the virtual machines on a Hyper-V parent&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;PS&amp;gt; winrm enumerate wmi/root/virtualization/msvm_computersystem /r:&lt;span style="background-color: #ffff00;"&gt;&amp;lt;Hyper-V Parent&amp;gt;&lt;/span&gt; /u:&lt;span style="background-color: #ffff00;"&gt;&amp;lt;username&amp;gt;&lt;/span&gt; /p:&lt;span style="background-color: #ffff00;"&gt;&amp;lt;password&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 60px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;Msvm_ComputerSystem&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AssignedNumaNodeList = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Caption = Virtual Machine&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CreationClassName = Msvm_ComputerSystem&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Description = Microsoft Virtual Machine&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ElementName = WSMANR2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EnabledDefault = 2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EnabledState = 2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HealthState = 5&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; InstallDate&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Datetime = 2011-07-25T20:31:41Z&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier; background-color: #ffff00;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Name = C4E916BB-92D5-4A40-97C1-0664FCC0123B&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NameFormat = null&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OnTimeInMilliseconds = 5774786&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OperationalStatus = 2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OtherEnabledState = null&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PrimaryOwnerContact = null&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PrimaryOwnerName = null&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProcessID = 2064&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RequestedState = 12&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ResetCapability = 1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Status = null&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; StatusDescriptions = Operating normally&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TimeOfLastConfigurationChange&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Datetime = 2011-08-22T17:33:46.726979Z&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TimeOfLastStateChange&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Datetime = 2011-08-22T17:33:46Z&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Build a credential object (this approach allows for the credentials to be hardcoded into a script, whereas the typical &amp;ldquo;get-credential&amp;rdquo; cmdlet will not allow the password to be stored in the script and enforces the more secure method of manual entry of the password).&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;PS&amp;gt; $password = convertto-securestring -String "&lt;span style="background-color: #ffff00;"&gt;&amp;lt;password&amp;gt;&lt;/span&gt;" -asplaintext -force&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;PS&amp;gt; $credential = new-object -typename System.Management.Automation.PSCredential -argumentlist "&lt;span style="background-color: #ffff00;"&gt;&amp;lt;username&amp;gt;&lt;/span&gt;",$password&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Execute the RequestStateChange method on the VM (acts like a Hard Reset for this example)&lt;/strong&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;PS&amp;gt; # Various supported state changes: 2=Turns the VM on, 3=Turns the VM off, 10=A hard reset of the VM, 32768=Pauses the VM, 32769=Saves the state of the VM&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,courier;"&gt;PS&amp;gt; invoke-wsmanaction -action RequestStateChange -resourceuri wmi/root/virtualization/msvm_computersystem -valueset @{RequestedState="10"} -selectorset @{Name="&lt;span style="background-color: #ffff00;"&gt;&amp;lt;VM Name/GUID from Above&amp;gt;&lt;/span&gt;"} -computername &lt;span style="background-color: #ffff00;"&gt;&amp;lt;Hyper-V Parent&amp;gt;&lt;/span&gt; -authentication default -credential $credential&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;That's it!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3448502" width="1" height="1"&gt;</description></item><item><title>Sample PowerShell 2.0 Remoting Commands</title><link>http://blogs.technet.com/b/otto/archive/2010/06/23/sample-powershell-2-0-remoting-commands.aspx</link><pubDate>Wed, 23 Jun 2010 14:41:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3339985</guid><dc:creator>ottoh1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/otto/rsscomments.aspx?WeblogPostID=3339985</wfw:commentRss><comments>http://blogs.technet.com/b/otto/archive/2010/06/23/sample-powershell-2-0-remoting-commands.aspx#comments</comments><description>&lt;p&gt;The following are a list of commands that I demonstrated at TechEd 2010 in New Orleans. Actually I should say that I intended to demo these commands, but wasn&amp;rsquo;t able to complete the entire list due to a conference wide network outage. :-(&lt;/p&gt;
&lt;p&gt;Many of these commands were intended to run against a real world web server in the Internet (&lt;a href="http://wsman.msft.net"&gt;http://wsman.msft.net&lt;/a&gt;). For one command (WS-Man ID), I&amp;rsquo;ll include the web server in the command syntax. Otherwise I&amp;rsquo;ll just use "&amp;lt;server name&amp;gt;" to specify the destination. In addition, my demo server is configured to respond to WS-Management from the original port 80 (rather than the new port 5985 which was changed in WinRM 2.0).&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note: If your client or end points are not Windows7 or Windows Server 2008 R2, then you will need to have PowerShell 2.0 installed on both systems. You can get the bits as Windows updates from &lt;/em&gt;&lt;a href="http://download.microsoft.com"&gt;&lt;em&gt;http://download.microsoft.com&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note: All commands are intended to be executed from PowerShell 2.0 or the PowerShell Integrated Scripting Environment (ISE).&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;strong&gt;&lt;span style="color: #003366;"&gt;Test WS-Man connectivity without authentication.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This is useful for making sure the network and the Windows Remote Manage service are operational and intentionally does not check credentials since that is usually another level of configuration can be tested on its own.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;&lt;strong&gt;&lt;span style="color: #800000;"&gt;test-wsman -computername wsman.msft.net:80 -authentication none&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Create a credential token to be used throughout the remaining commands.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;&lt;span style="color: #800000;"&gt;$cred = get-credential &amp;lt;administrator account name on end point&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #003366;"&gt;&lt;span style="font-size: small;"&gt;&lt;strong&gt;Test WS-Man connectivity with credentials (note version info is now displayed).&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;As mentioned above, it is helpful to be able to isolate authentication when troubleshooting management connectivity issues.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;&lt;span style="color: #800000;"&gt;test-wsman -computername &amp;lt;server name&amp;gt;:&amp;lt;port if other than 5985&amp;gt; -authentication default -credential $cred&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;strong&gt;&lt;span style="color: #003366;"&gt;Enumerate status for all Services.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This is merely using WS-Man as the transport for accessing WMI providers. In the past, DCOM was the transport, but had many limitations due to its firewall unfriendly nature.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;&lt;span style="color: #800000;"&gt;get-wsmaninstance -enumerate wmicimv2/win32_service -computername &amp;lt;server name&amp;gt;:&amp;lt;port if other than 5985&amp;gt; -authentication default -credential $cred&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;strong&gt;&lt;span style="color: #003366;"&gt;Enumerate status for IIS Service.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This demonstrates getting the state of a specific service (or element) by using the "selectorset" parameter.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;&lt;span style="color: #800000;"&gt;get-wsmaninstance wmicimv2/win32_service -selectorset @{name="w3svc"} -computername &amp;lt;server name&amp;gt;:&amp;lt;port if other than 5985&amp;gt; -authentication default -credential $cred&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;strong&gt;&lt;span style="color: #003366;"&gt;Stop and Start the IIS Service.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Again, this is merely using WS-Man as the transport in order to manipulate WMI methods that have been around since the dawn of time.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;&lt;span style="color: #800000;"&gt;invoke-wsmanaction -action stopservice -resourceuri wmicimv2/win32_service&amp;nbsp; -selectorset @{name="w3svc"} -computername &amp;lt;server name&amp;gt;:&amp;lt;port if other than 5985&amp;gt; -authentication default -credential $cred&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This will verify the state of the stopped service.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;&lt;span style="color: #800000;"&gt;get-wsmaninstance wmicimv2/win32_service -selectorset @{name="w3svc"} -computername &amp;lt;server name&amp;gt;:&amp;lt;port if other than 5985&amp;gt; -authentication default -credential $cred&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Now restart the IIS service.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;&lt;span style="color: #800000;"&gt;invoke-wsmanaction -action startservice -resourceuri wmicimv2/win32_service&amp;nbsp; -selectorset @{name="w3svc"} -computername &amp;lt;server name&amp;gt;:&amp;lt;port if other than 5985&amp;gt; -authentication default -credential $cred&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;strong&gt;&lt;span style="color: #003366;"&gt;Store Output into an Object.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;WMI instrumentation and actions are now very easy to automate with the addition of WS-Man as a transport for remoting and PowerShell for scripting. The example here shows how the WMI information can be pulled into an object and properly formatted.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;&lt;span style="color: #800000;"&gt;$operatingsystem = get-wsmaninstance -enumerate wmicimv2/win32_operatingsystem -computername &amp;lt;server name&amp;gt;:&amp;lt;port if other than 5985&amp;gt; -authentication default -credential $cred&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Show the output for the Last Boot Time for the end point.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;&lt;span style="color: #800000;"&gt;$operatingsystem.LastBootUpTime&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Format this Boot Time data into a proper .Net DateTime object.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;&lt;span style="color: #800000;"&gt;[datetime]$operatingsystem.LastBootUpTime.datetime&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;strong&gt;&lt;span style="color: #003366;"&gt;Query a VM Host&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;A good deal of Microsoft&amp;rsquo;s hypervisor&amp;rsquo;s (Hyper-V) as well as VMWare&amp;rsquo;s hypervisor&amp;rsquo;s instrumentation and management is exposed via WMI. The following command displays characteristics of the Hyper-V parent as well as all of its children.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;&lt;span style="color: #800000;"&gt;get-wsmaninstance -enumerate wmi/root/virtualization/Msvm_computersystem -computername &amp;lt;server name&amp;gt;:&amp;lt;port if other than 5985&amp;gt; -authentication default -credential $cred&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;strong&gt;&lt;span style="color: #003366;"&gt;Create a persistent connection to a Remote System.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This is using WS-Man to create a connection to the remote system, not PowerShell. Note that the port is not used in-line with the "ComputerName".&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="font-family: courier new,courier;"&gt;&lt;span style="color: #800000;"&gt;Connect-WSMan -computername &amp;lt;server name&amp;gt; -authentication default -credential $cred -port &amp;lt;port if other than 5985&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This will show the configuration of the remote system, including the listener.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;cd wsman:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The connection does need to be ended.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;disconnect-WSMan -computername wsman.msft.net&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="color: #003366;"&gt;&lt;strong&gt;Create and use a PowerShell Remoting Session.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Using PowerShell for remote management is much more powerful as it allows for the scripts (or script blocks) to be passed within the connection rather than requiring them to exist on the remote computer.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note: If the script or script block that is being passed to the remote computer is using any special modules, they will need to exist on the remote computer (modules are note passed with the script).&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;$wsman = new-pssession -computername &amp;lt;server name&amp;gt; -port &amp;lt;port if other than 5985&amp;gt; -authentication default -credential $cred&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This merely shows how to remotely execute a single PowerShell command on a remote machine and that the output is returned as a formatted object with the remote machine&amp;rsquo;s meta data attached to the results.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;invoke-command -session $wsman -scriptblock {get-process}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We&amp;rsquo;ll then put the results into an object. Notice now nicely the data in the object is formatted. This is not the case when non-PowerShell commands are executed remotely (see below).&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;$output = invoke-command -session $wsman -scriptblock {get-process}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This shows how to tear down the remote session.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;remove-pssession -session $wsman&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #003366;"&gt;&lt;span style="font-size: small;"&gt;&lt;strong&gt;Create and use a PowerShell Remoting Session on Several Servers&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;One of the most powerful features of PowerShell remoting is the ability to execute scripts on many servers simultaneously (knows as "fan out"). There is also the ability to throttle the number of servers that are simultaneously running scripts. The example below shows how to specify multiple servers within the command, but there are other (more programmatic) ways of doing this (see &amp;ldquo;get-help&amp;rdquo; for examples).&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;$several = new-pssession -computername &amp;lt;server name 1&amp;gt;,&amp;lt;server name 2&amp;gt;,&amp;lt;server name 3&amp;gt; -port &amp;lt;port if other than 5985&amp;gt; -authentication default -credential $cred&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;invoke-command -session $several -scriptblock {get-process}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;$output = invoke-command -session $several -scriptblock {get-process}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The following example show how a "fan out" PowerShell command can also be executed in the background and monitored by using the &amp;ldquo;asjob&amp;rdquo; flag.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;invoke-command -session $several -scriptblock {get-process} -asjob&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;get-job&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;receive-job -id &amp;lt;ID # listed from "get-job"&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The following example shows how the output is formatted if the executed command is not a PowerShell script or cmdlet.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;invoke-command -session $several -scriptblock {ipconfig /all}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;When the results are placed in a PowerShell object, the object is essentially an array of single lines of text.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;$output = invoke-command -session $several -scriptblock {ipconfig /all}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;remove-pssession -session $several&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;Enter into a PSSession&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The following examples show how to remote to a single end point and execute commands (in this case the commands will stop and restart the web service).&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;$wsman = new-pssession -computername &amp;lt;server name&amp;gt; -port &amp;lt;port if other than 5985&amp;gt; -authentication default -credential $cred&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;enter-pssession -session $wsman&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;net stop w3svc&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;net start w3svc&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;exit-pssession&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color: #800000;"&gt;&lt;span style="font-family: courier new,courier;"&gt;remove-pssession -session $wsman&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3339985" width="1" height="1"&gt;</description></item><item><title>Case Study: Using Diagnostics-Performance Events as a Desktop Health Indicator</title><link>http://blogs.technet.com/b/otto/archive/2010/03/15/case-study-using-diagnostics-performance-events-as-a-desktop-health-indicator.aspx</link><pubDate>Mon, 15 Mar 2010 16:42:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3319126</guid><dc:creator>ottoh1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/otto/rsscomments.aspx?WeblogPostID=3319126</wfw:commentRss><comments>http://blogs.technet.com/b/otto/archive/2010/03/15/case-study-using-diagnostics-performance-events-as-a-desktop-health-indicator.aspx#comments</comments><description>&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;em&gt;&lt;span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"&gt;Note: The solution below only pretains to new installations of Windows Vista+ since specific Diagnostics-Performance events are only repeated a small number of times before stopping. In addition, solutions to these events vary and depend on the source of the event. In the case below, drivers needed to be updated.&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;br /&gt;&lt;span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"&gt;Starting with Windows Vista, Microsoft started reporting on potential performance issues with the client operating system (Vista and Windows 7) by alerting on drivers, services, or applications that experience resource contention or take too long to respond during the "sleep", "resume", and "reboot" operations.&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"&gt;Recently while piloting Windows 7, a large enterprise customer collected all "Diagnostics-Performance" events from their Windows 7 clients using the built-in Windows Event Forwarding feature in order to gain a perspective on the general health of their client population. What they found was interesting. Essentially there were a set of out of date drivers that was impacting the performance and overall experience of a large percentage of the Windows 7 client population. In this case the solution was simple; upgrade the out of date driver.&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"&gt;Here are the details:&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"&gt;The Diagnostics-Performance channel is located in the following path within the Event Viewer: \Applications and Services Logs\Microsoft\Windows\Diagnostics-Performance\Operational&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;img style="width: 450px; height: 764px;" src="http://blogs.technet.com/photos/otto/images/3319124/original.aspx" width="450" height="764" mce_src="http://blogs.technet.com/photos/otto/images/3319124/original.aspx" /&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"&gt;In this case the Windows Event Forwarding design leveraged System Center Operations Manager (SCOM) to view and report on the collected events. The SCOM 2007 agent can forward collected events from the Event Collector into its database as follows:&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;img src="http://blogs.technet.com/photos/otto/images/3319125/original.aspx" mce_src="http://blogs.technet.com/photos/otto/images/3319125/original.aspx" /&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"&gt;&lt;em&gt;Note: Starting with Windows Server 2008 R2/Windows 7, the WS-Management transport for Windows Event Forwarding now uses port 5985 as the default port (rather than port 80). Security by obscurity? Since the Vista WS-Man client default port was 80 and since there is no Group Policy object for changing the default client WS-Man port, this customer creatively hard set the port within the Event Collector Server URI by using the following format: "&amp;lt;server name&amp;gt;:5985".&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"&gt;The following is a summary of all client events from the Diagnostics-Performance channel. Notice the USB Miniport driver accounted for over 40% of all performance degradation issues across their client base. Fortunately there was an update for this driver that solved the problem.&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;img style="width: 450px; height: 483px;" src="http://blogs.technet.com/photos/otto/images/3319123/original.aspx" width="450" height="483" mce_src="http://blogs.technet.com/photos/otto/images/3319123/original.aspx" /&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"&gt;The following is a specific example of the problematic event (Source: Diagnostics-Performance, Event ID: 351):&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;img style="width: 450px; height: 398px;" src="http://blogs.technet.com/photos/otto/images/3319122/original.aspx" width="450" height="398" mce_src="http://blogs.technet.com/photos/otto/images/3319122/original.aspx" /&gt;&lt;/p&gt;
&lt;table style="margin: auto auto auto 0.95in; border: currentColor; border-collapse: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-table-layout-alt: fixed;" class="MsoTableGrid" border="1" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes;"&gt;
&lt;td style="padding-bottom: 0in; padding-left: 5.4pt; width: 364.5pt; padding-right: 5.4pt; background: #365f91; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: accent1; mso-background-themeshade: 191; border: windowtext 1pt solid;" valign="top" width="486" colspan="2"&gt;
&lt;p style="text-align: center; margin: 0in 0in 0pt 0.75in;" class="MsoBodyText" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="color: white; mso-themecolor: background1;"&gt;Diagnostic-Performance Event&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 1;"&gt;
&lt;td style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 82.35pt; padding-right: 5.4pt; background: #c6d9f1; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: text2; mso-border-top-alt: solid windowtext .5pt; mso-background-themetint: 51;" valign="top" width="110"&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="color: #003366;" color="#003366"&gt;Log Name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 282.15pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;" valign="top" width="376"&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="color: #003366;" color="#003366"&gt;Microsoft-Windows-Diagnostics-Performance/Operational&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 2;"&gt;
&lt;td style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 82.35pt; padding-right: 5.4pt; background: #c6d9f1; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: text2; mso-border-top-alt: solid windowtext .5pt; mso-background-themetint: 51;" valign="top" width="110"&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="color: #003366;" color="#003366"&gt;Source&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 282.15pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;" valign="top" width="376"&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="color: #003366;" color="#003366"&gt;Microsoft-Windows-Diagnostics-Performance&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 3;"&gt;
&lt;td style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 82.35pt; padding-right: 5.4pt; background: #c6d9f1; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: text2; mso-border-top-alt: solid windowtext .5pt; mso-background-themetint: 51;" valign="top" width="110"&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="color: #003366;" color="#003366"&gt;Event ID&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 282.15pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;" valign="top" width="376"&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="color: #003366;" color="#003366"&gt;351&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 4;"&gt;
&lt;td style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 82.35pt; padding-right: 5.4pt; background: #c6d9f1; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: text2; mso-border-top-alt: solid windowtext .5pt; mso-background-themetint: 51;" valign="top" width="110"&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="color: #003366;" color="#003366"&gt;Task Category&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 282.15pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;" valign="top" width="376"&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="color: #003366;" color="#003366"&gt;Standby Performance Monitoring&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 5;"&gt;
&lt;td style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 82.35pt; padding-right: 5.4pt; background: #c6d9f1; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: text2; mso-border-top-alt: solid windowtext .5pt; mso-background-themetint: 51;" valign="top" width="110"&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="color: #003366;" color="#003366"&gt;Level&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 282.15pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;" valign="top" width="376"&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="color: #003366;" color="#003366"&gt;&lt;span style="font-size: 9pt; mso-bidi-font-size: 10.0pt;"&gt;Warning&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 6;"&gt;
&lt;td style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 82.35pt; padding-right: 5.4pt; background: #c6d9f1; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: text2; mso-border-top-alt: solid windowtext .5pt; mso-background-themetint: 51;" valign="top" width="110"&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="color: #003366;" color="#003366"&gt;Keywords&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 282.15pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;" valign="top" width="376"&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="color: #003366;" color="#003366"&gt;&lt;span style="font-size: 9pt; mso-bidi-font-size: 10.0pt;"&gt;Event Log&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow: 7; mso-yfti-lastrow: yes;"&gt;
&lt;td style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 82.35pt; padding-right: 5.4pt; background: #c6d9f1; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: text2; mso-border-top-alt: solid windowtext .5pt; mso-background-themetint: 51;" valign="top" width="110"&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="color: #003366;" color="#003366"&gt;Description&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 282.15pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;" valign="top" width="376"&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="font-size: 9pt; mso-bidi-font-size: 10.0pt;"&gt;&lt;span style="color: #003366;" color="#003366"&gt;This driver responded slower than expected to the resume request while servicing this device: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="font-size: 9pt; mso-bidi-font-size: 10.0pt;"&gt;&lt;span style="color: #003366;" color="#003366"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;Driver File Name: \Driver\usbuhci&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="font-size: 9pt; mso-bidi-font-size: 10.0pt;"&gt;&lt;span style="color: #003366;" color="#003366"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;Driver Friendly Name: UHCI USB Miniport Driver&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="font-size: 9pt; mso-bidi-font-size: 10.0pt;"&gt;&lt;span style="color: #003366;" color="#003366"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;Driver Version: 6.1.7265.0 (win7_rtm.090624-1905)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="font-size: 9pt; mso-bidi-font-size: 10.0pt;"&gt;&lt;span style="color: #003366;" color="#003366"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;Driver Total Time: 164ms&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="font-size: 9pt; mso-bidi-font-size: 10.0pt;"&gt;&lt;span style="color: #003366;" color="#003366"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;Driver Degradation Time: 59ms&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="font-size: 9pt; mso-bidi-font-size: 10.0pt;"&gt;&lt;span style="color: #003366;" color="#003366"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;Incident Time (UTC): ?2009?-?07?-?10T18:30:51.916061000Z&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="font-size: 9pt; mso-bidi-font-size: 10.0pt;"&gt;&lt;span style="color: #003366;" color="#003366"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;Device Name: PCI\VEN_8086&amp;amp;DEV_2937&amp;amp;SUBSYS_20F017AA&amp;amp;REV_03\3&amp;amp;21436425&amp;amp;0&amp;amp;D0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="font-size: 9pt; mso-bidi-font-size: 10.0pt;"&gt;&lt;span style="color: #003366;" color="#003366"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;Device Friendly Name: Intel(R) ICH9 Family USB Universal Host Controller - 2937&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="font-size: 9pt; mso-bidi-font-size: 10.0pt;"&gt;&lt;span style="color: #003366;" color="#003366"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;Device Total Time: 288ms&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;" class="MsoBodyText"&gt;&lt;span style="font-size: 9pt; mso-bidi-font-size: 10.0pt;"&gt;&lt;span style="color: #003366;" color="#003366"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;Device Degradation Time: 0ms&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"&gt;Although the "Diagnostics-Performance" channel can give another perspective of the overall health and user experience on the Windows 7 client, the standard "System" and "Application" logs&amp;nbsp;should still be foundational for determining client health. Unfortunately, due to the high number of events in these logs, an upfront investment is required in order to gather actionable events from a set of clients.&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3319126" width="1" height="1"&gt;</description></item><item><title>Forwarding Security Events from Windows XP, Server 2003, and Vista/Server 2008</title><link>http://blogs.technet.com/b/otto/archive/2009/06/22/forwarding-security-events-from-windows-xp-server-2003-and-vista-server-2008.aspx</link><pubDate>Mon, 22 Jun 2009 20:54:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3257545</guid><dc:creator>ottoh1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/otto/rsscomments.aspx?WeblogPostID=3257545</wfw:commentRss><comments>http://blogs.technet.com/b/otto/archive/2009/06/22/forwarding-security-events-from-windows-xp-server-2003-and-vista-server-2008.aspx#comments</comments><description>&lt;P&gt;Security events are different than other Windows events because they require a special level of authentication/credentials in order to read or forward these events. Different configurations are required depending on which Windows platform is the client. The event collector functionality is only implemented in Windows Vista or Server 2003 R2 (or later).&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/3257840/original.aspx" mce_src="http://blogs.technet.com/photos/otto/images/3257840/original.aspx"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following table illustrates the special configurations required for each platform:&lt;/P&gt;
&lt;P mce_keep="true"&gt;
&lt;TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; MARGIN: auto auto auto 36.9pt; WIDTH: 445.5pt; BORDER-COLLAPSE: collapse; BORDER-TOP: medium none; BORDER-RIGHT: medium none; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt" class=MsoTableGrid border=1 cellSpacing=0 cellPadding=0 width=594 class="MsoTableGrid"&gt;
&lt;TBODY&gt;
&lt;TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; PADDING-LEFT: 5.4pt; WIDTH: 121.5pt; PADDING-RIGHT: 5.4pt; BACKGROUND: #365f91; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: accent1; mso-background-themeshade: 191" vAlign=top width=162&gt;
&lt;P style="TEXT-ALIGN: center; MARGIN: 0in 0in 0pt" class=MsoBodyText align=center&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: white; mso-themecolor: background1"&gt;Platform&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; PADDING-LEFT: 5.4pt; WIDTH: 4.5in; PADDING-RIGHT: 5.4pt; BACKGROUND: #365f91; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: accent1; mso-background-themeshade: 191; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=432&gt;
&lt;P style="TEXT-ALIGN: center; MARGIN: 0in 0in 0pt" class=MsoBodyText align=center&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: white; mso-themecolor: background1"&gt;Configuration Requirement&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 1"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 121.5pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=162&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoBodyText&gt;&lt;FONT color=#003366&gt;XP SP2+&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 4.5in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=432&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoBodyText&gt;&lt;FONT color=#003366&gt;The “Windows Remote Management” Service needs to run as “Local System” (make sure you're okay with this elevation - it does have potential security ramifications)&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 2"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 121.5pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=162&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoBodyText&gt;&lt;FONT color=#003366&gt;Server 2003&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 4.5in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=432&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoBodyText&gt;&lt;FONT color=#003366&gt;The following “CustomSD” key needs to be set within “HKLM/SYSTEM/CCS/Services/EventLog/Security” to “O:BAG:SYD:(A;;CC;;;NS)”&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 3; mso-yfti-lastrow: yes"&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 121.5pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=162&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoBodyText&gt;&lt;FONT color=#003366&gt;Vista, Server 2008, and beyond&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 4.5in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=432&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoBodyText&gt;&lt;FONT color=#003366&gt;Add “Network Service” to the “Event Log Readers” Local Security Group&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;EM&gt;Note: A popular scenario&amp;nbsp;includes forwarding Security Events from a Domain Controller in order to get an enterprise view for auditing and security monitoring. Due to the large number of Security Events that tend to be generated on Domain Controllers, the Event Forwarding subscription should not request that Forwarded Events be "Rendered". Event rendering for a large number of events will consume a large amount of processing resources on the client. The "ContentFormat" of the subscription needs to be set to "Events" rather than the default "RenderedText". This change can be made via "WECUTIL.EXE".&lt;/EM&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;&amp;lt;ContentFormat&amp;gt;&lt;STRONG&gt;Events&lt;/STRONG&gt;&amp;lt;/ContentFormat&amp;gt;&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&lt;EM&gt;Note: In addition, Security events are typically considered time sensitive and it's desirable to forward them immediately, rather than at a set interval. The following "MaxItems" setting for the subscription insures that events are forwarded as they occur (only valid for "Push" subscriptions).&lt;/EM&gt;&lt;/P&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;wecutil ss &amp;lt;subscription name&amp;gt; /cm:Custom /dmi:1&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;More details can be found below:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;WMI Blog on this topic (adds a little more background info): &lt;A href="http://blogs.msdn.com/wmi/archive/2009/04/06/forwarding-security-related-events-from-xp-win2k3-vista-using-winrm-wsman-event-forwarding.aspx"&gt;http://blogs.msdn.com/wmi/archive/2009/04/06/forwarding-security-related-events-from-xp-win2k3-vista-using-winrm-wsman-event-forwarding.aspx&lt;/A&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Setting Event Log Security via Group Policy (KB Article): &lt;A href="http://support.microsoft.com/default.aspx/kb/323076"&gt;http://support.microsoft.com/default.aspx/kb/323076&lt;/A&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Event Forwarding Plug-In for XP SP2+ and Server 2003 SP1+: &lt;A href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=845289ca-16cc-4c73-8934-dd46b5ed1d33" mce_href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=845289ca-16cc-4c73-8934-dd46b5ed1d33"&gt;http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=845289ca-16cc-4c73-8934-dd46b5ed1d33&lt;/A&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3257545" width="1" height="1"&gt;</description></item><item><title>Hyper-V Virtual Identification</title><link>http://blogs.technet.com/b/otto/archive/2008/08/04/hyper-v-virtual-identification.aspx</link><pubDate>Mon, 04 Aug 2008 19:00:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3098340</guid><dc:creator>ottoh1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/otto/rsscomments.aspx?WeblogPostID=3098340</wfw:commentRss><comments>http://blogs.technet.com/b/otto/archive/2008/08/04/hyper-v-virtual-identification.aspx#comments</comments><description>&lt;P&gt;Since virtual machines can be easily moved between physical hosts (parents), it becomes important to track where virtual machines are physically residing for both asset management as well as troubleshooting purposes. The following post focuses on discovering the relationship between virtual hosts (parents) and the virtual machines (children) from both the perspective of the parent as well as the perspective of the child.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH: 500px; HEIGHT: 322px" height=322 src="http://blogs.technet.com/photos/otto/images/3098393/original.aspx" width=500 mce_src="http://blogs.technet.com/photos/otto/images/3098393/original.aspx"&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Note: The following examples use the WinRM and WinRS&amp;nbsp;command-line utilities which shipped with Windows Vista and Windows Server 2008, but are also available as an Out-Of-Band install for Windows XP SP2+ and Windows Server 2003 SP1+ &lt;/EM&gt;&lt;A class="" title="WinRM v1.1" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=845289ca-16cc-4c73-8934-dd46b5ed1d33&amp;amp;DisplayLang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=845289ca-16cc-4c73-8934-dd46b5ed1d33&amp;amp;DisplayLang=en"&gt;&lt;EM&gt;here&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Query the Parent:&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Most commonly used for asset collection, this model gathers the names (and other virtual machine characteristics) of all the children running on a virtual host. This method queries the Hyper-V specific WMI provider/class by using the following command.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;
&lt;P&gt;winrm enumerate wmi/root/virtualization/msvm_computersystem /r:&amp;lt;remote Hyper-V Host&amp;gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;With the following sample output:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;
&lt;P&gt;Msvm_ComputerSystem&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AssignedNumaNodeList = 0&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Caption = Virtual Machine&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CreationClassName = Msvm_ComputerSystem&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Description = Microsoft Virtual Machine&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;ElementName = PROV-XP&lt;/STRONG&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EnabledDefault = 2&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EnabledState = 2&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HealthState = 5&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; InstallDate&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Datetime = 2008-07-01T21:47:02Z&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Name = 31F497F1-2437-4E89-8308-BE07FB5C14C2&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NameFormat = null&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OnTimeInMilliseconds = 432464839&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OperationalStatus = 2&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OtherEnabledState = null&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PrimaryOwnerContact = null&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PrimaryOwnerName = OTTOH-HOST\Administrator&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProcessID = 2628&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RequestedState = 12&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ResetCapability = 1&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Status = null&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TimeOfLastConfigurationChange&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Datetime = 2008-07-30T17:07:06Z&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TimeOfLastStateChange&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Datetime = 2008-07-30T17:07:06Z&lt;/P&gt;&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Query the Child:&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Most commonly used for troubleshooting scenarios where a virtual machine is being evaulated and needs to be queried in order to determine its physical host (parent). The following command queries the registry on the child in order to determine its host (parent):&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH: 500px; HEIGHT: 301px" height=301 src="http://blogs.technet.com/photos/otto/images/3098386/original.aspx" width=500 mce_src="http://blogs.technet.com/photos/otto/images/3098386/original.aspx"&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Remote Access Method #1&lt;/STRONG&gt; (the /f parameter merely structures the output in XML – handy for scripting, especially in PowerShell):&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;
&lt;P&gt;winrm invoke GetStringValue wmi/root/default/StdRegProv @{hDefKey="2147483650";sSubKeyName="Software\Microsoft\Virtual Machine\Guest\Parameters";sValueName="PhysicalHostNameFullyQualified"} /r:&amp;lt;Remote VM&amp;gt; /u:&amp;lt;Username&amp;gt; /p:&amp;lt;Password&amp;gt; /f:pretty&lt;/P&gt;&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Remote Access Method #2:&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;
&lt;P&gt;winrs /r:&amp;lt;Remote VM&amp;gt; /u:&amp;lt;Username&amp;gt; /p:&amp;lt;Password&amp;gt; reg query "HKLM\Software\Microsoft\Virtual Machine\Guest\Parameters" /v PhysicalHostNameFullyQualified&lt;/P&gt;&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;Note: The first method demonstrates a powerful way to access the value of any registry key using the ‘StdRegProv’ WMI provider via WS-Man/WinRM for remote transport. Other registry hives can be accessed with the following hDefKey values: HKLM=2147483650, HKCU=2147483649, HKCR=2147483648, HKEY_USERS=2147483651.&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3098340" width="1" height="1"&gt;</description></item><item><title>Quick and Dirty Large Scale Eventing for Windows</title><link>http://blogs.technet.com/b/otto/archive/2008/07/08/quick-and-dirty-enterprise-eventing-for-windows.aspx</link><pubDate>Tue, 08 Jul 2008 18:25:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3085618</guid><dc:creator>ottoh1</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/otto/rsscomments.aspx?WeblogPostID=3085618</wfw:commentRss><comments>http://blogs.technet.com/b/otto/archive/2008/07/08/quick-and-dirty-enterprise-eventing-for-windows.aspx#comments</comments><description>&lt;P&gt;One of the least known yet most powerful management features to ship with Windows Vista&amp;nbsp;and Windows Server 2008 is built-in Event Forwarding which enables large scale health and state monitoring of a Windows environment (assuming health and state&amp;nbsp;can be determined from Windows Events - which&amp;nbsp;they usually can). Not only is this feature built into the latest versions of Windows, but it's also available for down-level OSs like Windows&amp;nbsp;XP SP2+ and Windows Server 2003 SP1+ (&lt;A class="" title="WS-Man 1.1" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=845289ca-16cc-4c73-8934-dd46b5ed1d33&amp;amp;DisplayLang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=845289ca-16cc-4c73-8934-dd46b5ed1d33&amp;amp;DisplayLang=en"&gt;here&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Note:&lt;/EM&gt;&amp;nbsp;True enterprise class Windows eventing is included with enterprise monitoring solutions like System Center Operations Manager.&lt;/P&gt;
&lt;P&gt;This new Windows Event Forwarding (also known as Windows Eventing 6.0) is exceptional for the following reasons:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;STRONG&gt;Standards Based:&lt;/STRONG&gt; No really! It leverages the DMTF WS-Eventing standard which allows it to interoperate with other WS-Man implementations (see &lt;A class="" href="http://sourceforge.net/projects/openwsman/" mce_href="http://sourceforge.net/projects/openwsman/"&gt;OpenWSMAN&lt;/A&gt; at SourceForge).&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Agentless:&amp;nbsp;&lt;/STRONG&gt;Event Forwarding and&amp;nbsp;Event Collection are&amp;nbsp;included in the OS by default&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Down-Level Support:&lt;/STRONG&gt; Event Forwarding&amp;nbsp;is available for Windows XP SP2+ and Windows Server 2003 SP1+&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Multi-Tier:&lt;/STRONG&gt; Forwarding architecture is very scalable where a "Source Computer" may forward to a large number of collectors and collectors may forward to collectors&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Scalable:&lt;/STRONG&gt; Event Collection&amp;nbsp;is very scalable (available in Windows Vista as well) where the collector can maintain subscriptions with a large number of "Source Computers" as well as process a large number of events per second&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Group Policy Aware:&lt;/STRONG&gt; The entire model is configurable by Group Policy&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Schematized Events:&lt;/STRONG&gt; Windows Events are now schematized and rendered in XML which enables many&amp;nbsp;scripting and export scenarios&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Pre-Rendering:&lt;/STRONG&gt; Forwarded Windows Events can now be pre-rendered on the Source Computer negating the need for local applications to render Windows Events&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Resiliency:&lt;/STRONG&gt; Designed&amp;nbsp;to enable mobile scenarios where laptops may be disconnected from the collector for extended periods of time without event loss (except when logs wrap) as well as leveraging TCP for guaranteed delivery&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Security: &lt;/STRONG&gt;Certificate based encryption via Kerberos or HTTPS&lt;/LI&gt;&lt;/OL&gt;
&lt;P mce_keep="true"&gt;This implementation will walk through the following example design where via Group Policy a domain computer group will be configured to forwared Windows Events to a single collector:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG style="WIDTH: 617px; HEIGHT: 423px" height=423 src="http://blogs.technet.com/photos/otto/images/3085654/original.aspx" width=617 mce_src="http://blogs.technet.com/photos/otto/images/3085654/original.aspx"&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Implementation&amp;nbsp;steps are as follows:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Step 1: Create&amp;nbsp;Event Forwarding Subscription&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Step 2: Configure WinRM Group Policy&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Step 3: Configure Event Forward Group Policy&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Step 4: Test&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Step 1: Create the Event Forwarding Subscription on the Event Collector&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;In the Windows Event Forwarding architecture, the subscription definition is held and maintained on the Collector in order to reduce the number of touch-points in case a subscription needs to be created or&amp;nbsp;modified. Creating the subscription is accomplished through the new Event Viewer user interface by selecting the 'Create Subscription' action when the 'Subscriptions' branch is highlighted. The Subscription may also be created via the "WECUTIL" command-line utility.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&lt;EM&gt;Note:&lt;/EM&gt; Both Windows Vista and Windows Server 2008 can be event collectors (this feature is not supported for down-level). Although there are no built-in limitations when Vista is a collector, Server 2008 will scale much better in high volume scenarios.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG style="WIDTH: 739px; HEIGHT: 632px" height=632 src="http://blogs.technet.com/photos/otto/images/3085598/original.aspx" width=739 mce_src="http://blogs.technet.com/photos/otto/images/3085598/original.aspx"&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;Although the above subscription is configured to leverage Group Policy, the subscription can be configured in a stand-alone mode (see the "Collector Initiated" option). In addition, this subscription is designed to gather all events from the "Application" and "System" logs that have a level of "Critical", "Error", or "Warning". This event scope can be expanded to gather all events from these logs&amp;nbsp;or even add&amp;nbsp;additional logs (like the "Security" log).&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;Lastly, the subscription is configured to forward events as quickly as possible with the advanced settings delivery option of "Minimize Latency". The default setting of "Normal" would only forward events every 15 minutes (which may be more desirable depending the the Collector and Source Computer resources).&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG style="WIDTH: 347px; HEIGHT: 153px" height=153 src="http://blogs.technet.com/photos/otto/images/3085599/original.aspx" width=347 mce_src="http://blogs.technet.com/photos/otto/images/3085599/original.aspx"&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;If Group Policy is not being used,&amp;nbsp;configure the "Subscription type" to be "Collector Initiated". In this case Source Computers will need to be&amp;nbsp;manually added to the&amp;nbsp;Subscription either through&amp;nbsp;the Subscription configuration or the&amp;nbsp;"WECUTIL"&amp;nbsp;command-line utility (which can also be scripted&amp;nbsp;using PowerShell, but that's another topic).&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&lt;EM&gt;Note:&lt;/EM&gt; In cases where there Source Computer is generating a large volume of forwarded events (e.g. Security events from a Domain Controller), use WECUTIL on the collector to disable event rendering for the subscription. The task of pre-rendering an event on the source computer can be CPU intensive for a large number of events.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Step 2: Configure Group Policy to enable Windows Remote Management on the Source Computers (clients)&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;Group Policy can be used to enable and configure Windows Remote Management (WinRM or WS-Man) on the Source Computers. WinRM is required by Windows Event Forwarding as WS-Man is the protocol used by WS-Eventing. The following shows the Group Policy branch locations for configuring both WinRM and Event Forwarding:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG style="WIDTH: 283px; HEIGHT: 508px" height=508 src="http://blogs.technet.com/photos/otto/images/3085595/original.aspx" width=283 mce_src="http://blogs.technet.com/photos/otto/images/3085595/original.aspx"&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;The following GP setting will enable WinRM on the client as well as configure a Listener that will accept packets from &lt;STRONG&gt;ANY&lt;/STRONG&gt; source.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG style="WIDTH: 323px; HEIGHT: 358px" height=358 src="http://blogs.technet.com/photos/otto/images/3085597/original.aspx" width=323 mce_src="http://blogs.technet.com/photos/otto/images/3085597/original.aspx"&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&lt;EM&gt;Note:&lt;/EM&gt; This Listener configuration should only be used in a trusted network environment. If the environment is not trusted (like the Internet), then configure only&amp;nbsp;specific IP Addresses or&amp;nbsp;ranges in the IPv4 and IPv6 filters.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;To configure WinRM outside of Group Policy, run the following command on the Source Computer (also see the above Note):&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;winrm quickconfig&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Step 3: Configure Group Policy to enable Windows Event Forwarding on the Source Computers&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;As with WinRM, Group Policy can be used to configure Source Computers (Clients) to forward events to a collector (or set of collectors). The policy is very simple. It merely tells the Source Computer to contact a specific FQDN (Fully Qualified Domain Name) or IP Address and request subscription specifics. All of the other subscription details are held on the Collector.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG style="WIDTH: 513px; HEIGHT: 426px" height=426 src="http://blogs.technet.com/photos/otto/images/3085596/original.aspx" width=513 mce_src="http://blogs.technet.com/photos/otto/images/3085596/original.aspx"&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;If Group Policy is not being used, then there is nothing to do here as the "Collector Initiated" Subscription will proactively reach out to the Source Computer.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Step 4: Test Event Forwarding&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;If all of the Event Forwarding components are functioning (and there's minimal network latency), a test event created on the Source Computer should arrive in the Collector's "Forwarded Events" log within 60 seconds. Create a test event with the following command:&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;
&lt;P mce_keep="true"&gt;eventcreate /id 999 /t error /l application /d "Test event."&lt;/P&gt;&lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&lt;IMG style="WIDTH: 601px; HEIGHT: 297px" height=297 src="http://blogs.technet.com/photos/otto/images/3085601/original.aspx" width=601 mce_src="http://blogs.technet.com/photos/otto/images/3085601/original.aspx"&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;This event should appear on the Collector as follows:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG style="WIDTH: 560px; HEIGHT: 390px" height=390 src="http://blogs.technet.com/photos/otto/images/3085602/original.aspx" width=560 mce_src="http://blogs.technet.com/photos/otto/images/3085602/original.aspx"&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;If the event doesn't appear, perform the following troubleshooting steps:&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Troubleshooting Step 1: Has Policy Been Applied to the Source Computer?&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;This can be forced by running the following command on the Source Computer:&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;
&lt;P mce_keep="true"&gt;gpupdate /force&lt;/P&gt;&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Troubleshooting Step 2: Can the Collector Reach The Source Computer via WinRM?&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;Run the following command on the Collector&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;winrm id /r:&amp;lt;Source Computer&amp;gt; /a:none&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;/SPAN&gt;&lt;STRONG&gt;Troubleshooting Step 3: Is the Collector Using the Right Credentials?&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;Run the following command on the Collector&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;winrm id /r:&amp;lt;Source Computer&amp;gt; /u:&amp;lt;username&amp;gt; /p:&amp;lt;password&amp;gt;&lt;/P&gt;
&lt;P&gt;&lt;/SPAN&gt;&lt;EM&gt;Note:&lt;/EM&gt; These are the credentials defined in the Subscription on the Collector. The credentials don't need to be in the local Administrators group on the Source Computer, they just need to be in the "Event Log Readers" group on the Source Computer (local Administrators will also work).&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Troubleshooting Step 4: Has the Source Computer Registered with the Collector?&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;Run the following command on the Collector&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;wecutil gr &amp;lt;subscription name&amp;gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;This will list all the registered Source Computers (note if the Subscription is "Collector Initiated" then this will list all configured Source Computers), their state (from the Collector's perspective), and their last heartbeat time.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Enjoy!&lt;/STRONG&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3085618" width="1" height="1"&gt;</description></item><item><title>Reference The Event That Triggered Your Task</title><link>http://blogs.technet.com/b/otto/archive/2007/11/09/find-the-event-that-triggered-your-task.aspx</link><pubDate>Sat, 10 Nov 2007 00:29:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:2383596</guid><dc:creator>ottoh1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/otto/rsscomments.aspx?WeblogPostID=2383596</wfw:commentRss><comments>http://blogs.technet.com/b/otto/archive/2007/11/09/find-the-event-that-triggered-your-task.aspx#comments</comments><description>&lt;P&gt;Task Scheduler 2.0 (which shipped with Vista and Windows Server 2008) is a complete re-write of the built-in Windows Task Scheduler. Task Scheduler 2.0 is a fantastic automation tool that includes new powerful triggers like "from Event". From a task's perspective, I'm going to outline how to determine which event is responsible for triggering a task. This can be helpful when the task may want to branch depending on the type of event, or the task may want to report more information about the specific event content.&lt;/P&gt;
&lt;P&gt;For example, suppose you want a task to notify you every time a Service is Stopped on your server. This would require a task to inspect the details of the specific Service Control Manager event in order to figure out the affected Service (by name) as well as the state change (was it stopped or started?). This is also a good example because&amp;nbsp;the Service Start/Stopped events use the same EventID, so further event inspection of the event content&amp;nbsp;is required.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Step 1: Create the Task&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Create your task (either by selecting "Attach A Task To This Event..." from the Event Viewer, or manually selecting the "On an event" Trigger when building the Task inside the Task Scheduler.&lt;/P&gt;
&lt;P&gt;Event Viewer Example:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/2383627/original.aspx" mce_src="http://blogs.technet.com/photos/otto/images/2383627/original.aspx"&gt;&lt;/P&gt;
&lt;P&gt;Task Scheduler Example:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/2383541/original.aspx" mce_src="http://blogs.technet.com/photos/otto/images/2383541/original.aspx"&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Step 2: Export the Task&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;From within Task Scheduler, export the newly created task (as an XML file)&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/2383593/original.aspx" mce_src="http://blogs.technet.com/photos/otto/images/2383593/original.aspx"&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Step 3: Modify the Task&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Use Notepad (or your text editor of choice - keep in mind the text editor must honor unicode which notepad does) to add the Event parameters you which to pass along to your task. The event parameters below are the most useful for event identification. Notice the entire node &amp;lt;ValueQueries&amp;gt; and its children need to be added to the EventTrigger branch.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/2383318/original.aspx" mce_src="http://blogs.technet.com/photos/otto/images/2383318/original.aspx"&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Step 4: Pass the Values to Your Action&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;The following example shows how the event values can be used the simple Message Box action.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/2383305/original.aspx" mce_src="http://blogs.technet.com/photos/otto/images/2383305/original.aspx"&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Step 5: The Result&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Now&amp;nbsp;the following message box will fire every time the Event Trigger condition is met. Notice the 3 Event parameters that are displayed in the message box.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/2383165/original.aspx" mce_src="http://blogs.technet.com/photos/otto/images/2383165/original.aspx"&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Step 6: Next Steps - Display The Whole Source Event&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;With the above parameters, the specific event can be tracked down for ever more information about the event. For example, the following WEVTUTIL.EXE utility can be used to display the specific event (substitute the variables $eventLog and $eventRecordID as needed):&lt;/P&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;
&lt;P&gt;wevtutil qe $eventLog /f:RenderedXML /e:EVENTS /q:"&amp;lt;QueryList&amp;gt;&amp;lt;Query Id='0' Path='$eventLog'&amp;gt;&amp;lt;Select Path='$eventLog'&amp;gt;*[System[(EventRecordID=$eventRecordID)]]&amp;lt;/Select&amp;gt;&amp;lt;/Query&amp;gt;&amp;lt;/QueryList&amp;gt;"&lt;/P&gt;&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Step 7: Next Steps -&amp;nbsp;Find Other Event Parameters&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Any Event Parameter can be passed to a task. Event parameters can be found by inspecting the specific Event's Properties&amp;nbsp;using the Event Viewer.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/2383702/original.aspx" mce_src="http://blogs.technet.com/photos/otto/images/2383702/original.aspx"&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Example Task:&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;
&lt;P&gt;&amp;lt;?xml version="1.0" encoding="UTF-16"?&amp;gt;&lt;BR&gt;&amp;lt;Task version="1.2" xmlns="&lt;A href="http://schemas.microsoft.com/windows/2004/02/mit/task"&gt;http://schemas.microsoft.com/windows/2004/02/mit/task&lt;/A&gt;"&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;RegistrationInfo&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Date&amp;gt;2007-11-09T09:21:33.3102706&amp;lt;/Date&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Author&amp;gt;Otto Helweg&amp;lt;/Author&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/RegistrationInfo&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;Triggers&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;EventTrigger&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Enabled&amp;gt;true&amp;lt;/Enabled&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Subscription&amp;gt;&amp;amp;lt;QueryList&amp;amp;gt;&amp;amp;lt;Query Id="0" Path="Application"&amp;amp;gt;&amp;amp;lt;Select Path="Application"&amp;amp;gt;*&amp;amp;lt;/Select&amp;amp;gt;&amp;amp;lt;Select Path="Security"&amp;amp;gt;*&amp;amp;lt;/Select&amp;amp;gt;&amp;amp;lt;Select Path="System"&amp;amp;gt;*&amp;amp;lt;/Select&amp;amp;gt;&amp;amp;lt;/Query&amp;amp;gt;&amp;amp;lt;/QueryList&amp;amp;gt;&amp;lt;/Subscription&amp;gt;&lt;BR&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ValueQueries&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value name="eventChannel"&amp;gt;Event/System/Channel&amp;lt;/Value&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value name="eventRecordID"&amp;gt;Event/System/EventRecordID&amp;lt;/Value&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value name="eventSeverity"&amp;gt;Event/System/Level&amp;lt;/Value&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ValueQueries&amp;gt;&lt;BR&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/EventTrigger&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/Triggers&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;Principals&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Principal id="Author"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;UserId&amp;gt;SomeUser&amp;lt;/UserId&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;LogonType&amp;gt;InteractiveToken&amp;lt;/LogonType&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RunLevel&amp;gt;LeastPrivilege&amp;lt;/RunLevel&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Principal&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/Principals&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;Settings&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;IdleSettings&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Duration&amp;gt;PT10M&amp;lt;/Duration&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;WaitTimeout&amp;gt;PT1H&amp;lt;/WaitTimeout&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;StopOnIdleEnd&amp;gt;true&amp;lt;/StopOnIdleEnd&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RestartOnIdle&amp;gt;false&amp;lt;/RestartOnIdle&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/IdleSettings&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MultipleInstancesPolicy&amp;gt;Queue&amp;lt;/MultipleInstancesPolicy&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DisallowStartIfOnBatteries&amp;gt;true&amp;lt;/DisallowStartIfOnBatteries&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;StopIfGoingOnBatteries&amp;gt;true&amp;lt;/StopIfGoingOnBatteries&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;AllowHardTerminate&amp;gt;true&amp;lt;/AllowHardTerminate&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;StartWhenAvailable&amp;gt;false&amp;lt;/StartWhenAvailable&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RunOnlyIfNetworkAvailable&amp;gt;false&amp;lt;/RunOnlyIfNetworkAvailable&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;AllowStartOnDemand&amp;gt;true&amp;lt;/AllowStartOnDemand&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Enabled&amp;gt;true&amp;lt;/Enabled&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Hidden&amp;gt;false&amp;lt;/Hidden&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RunOnlyIfIdle&amp;gt;false&amp;lt;/RunOnlyIfIdle&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;WakeToRun&amp;gt;false&amp;lt;/WakeToRun&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ExecutionTimeLimit&amp;gt;P3D&amp;lt;/ExecutionTimeLimit&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Priority&amp;gt;7&amp;lt;/Priority&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/Settings&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;Actions Context="Author"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ShowMessage&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Title&amp;gt;Event Parameters&amp;lt;/Title&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;&amp;lt;Body&amp;gt;Record ID = $(eventRecordID)&lt;BR&gt;Log = $(eventChannel)&lt;BR&gt;Severity = $(eventSeverity)&amp;lt;/Body&amp;gt;&lt;BR&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ShowMessage&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/Actions&amp;gt;&lt;BR&gt;&amp;lt;/Task&amp;gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=2383596" width="1" height="1"&gt;</description></item><item><title>Quick and Dirty Web Site Monitoring with PowerShell</title><link>http://blogs.technet.com/b/otto/archive/2007/08/23/quick-and-dirty-web-site-monitoring-with-powershell.aspx</link><pubDate>Thu, 23 Aug 2007 19:44:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:1810231</guid><dc:creator>ottoh1</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/otto/rsscomments.aspx?WeblogPostID=1810231</wfw:commentRss><comments>http://blogs.technet.com/b/otto/archive/2007/08/23/quick-and-dirty-web-site-monitoring-with-powershell.aspx#comments</comments><description>&lt;P&gt;The other day&amp;nbsp;Mark noticed that redirections for our &lt;A href="http://www.sysinternals.com/"&gt;http://www.sysinternals.com/&lt;/A&gt; URL were intermittently failing. In order to get more objective data, I built a script that tested the URL every 5 seconds, and reported back Success or Failure as well as performance (how long it took to completely download base HTML content). I found that PowerShell provided&amp;nbsp;an easy way to use the&amp;nbsp;WebClient .Net object and evaluate the returned HTML content.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/1810288/original.aspx" mce_src="http://blogs.technet.com/photos/otto/images/1810288/original.aspx"&gt;&lt;/P&gt;
&lt;P&gt;Don't have PowerShell? Get it &lt;A class="" href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx" mce_href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Example 1: Single Site Monitoring&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The following example opens a URL every 5 minutes, tests the content, and measures the time it took to download the HTML for the page. Notice that all the HTML is dumped into a big fat string. The string is then searched for specific text that is known to be in the requested page. Note that this script runs forever and can be stopped with a &amp;lt;Ctrl&amp;gt;&amp;nbsp;'C'.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Example PowerShell script:&lt;/P&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;$webClient = new-object System.Net.WebClient&lt;BR&gt;$webClient.Headers.Add("user-agent", "PowerShell Script")&lt;/P&gt;
&lt;P&gt;while (1 -eq 1) {&lt;BR&gt;&amp;nbsp;&amp;nbsp; $output = ""&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; $startTime = get-date&lt;BR&gt;&amp;nbsp;&amp;nbsp; $output = $webClient.DownloadString("&lt;A href="http://www.sysinternals.com/"&gt;http://www.sysinternals.com/&lt;/A&gt;")&lt;BR&gt;&amp;nbsp;&amp;nbsp; $endTime = get-date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if ($output -like "*Mark Russinovich*") {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Success`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;} else {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Fail`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds"&lt;BR&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; sleep(300)&lt;BR&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/1810007/original.aspx" mce_src="http://blogs.technet.com/photos/otto/images/1810007/original.aspx"&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Example 2:&amp;nbsp;Monitoring and Alerting for Multiple Web Sites&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This script monitors multiple URLs (or web sites), and incorporates e-mail alerting and logging. Unlike the above script, it is designed to be triggered from the Windows Task Scheduler (or some other job scheduler) rather than running forever in a loop. Notice that one of the URLs is actually a zipped file and PowerShell has no problem evaluating it as a string.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Example PowerShell script:&lt;/P&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;# Collects all named paramters (all others end up in $Args)&lt;BR&gt;param($alert)&lt;/P&gt;
&lt;P&gt;# Display Help&lt;BR&gt;if (($Args[0] -eq "-?") -or ($Args[0] -eq "-help")) {&lt;BR&gt;&amp;nbsp;&amp;nbsp; ""&lt;BR&gt;&amp;nbsp;&amp;nbsp; "Usage: SysinternalsSiteTest.ps1 -alert &amp;lt;address&amp;gt; -log"&lt;BR&gt;&amp;nbsp;&amp;nbsp; "&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -alert &amp;lt;address&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Send e-mail alerts"&lt;BR&gt;&amp;nbsp;&amp;nbsp; "&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -log&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Log results"&lt;BR&gt;&amp;nbsp;&amp;nbsp; ""&lt;BR&gt;&amp;nbsp;&amp;nbsp; "Example: SysinternalsSiteTest.ps1 -alert &lt;A href="mailto:somebody@nospam.com"&gt;somebody@nospam.com&lt;/A&gt; -log"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;""&lt;BR&gt;&amp;nbsp;&amp;nbsp; exit&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;# Create the variables&lt;BR&gt;$global:GArgs = $Args&lt;/P&gt;
&lt;P&gt;$urlsToTest = @{}&lt;BR&gt;$urlsToTest["Sysinternals Redirect"] = "&lt;A href="http://www.sysinternals.com/"&gt;http://www.sysinternals.com&lt;/A&gt;"&lt;BR&gt;$urlsToTest["TechNet Redirect"] = "&lt;A href="http://www.microsoft.com/sysinternals"&gt;http://www.microsoft.com/sysinternals&lt;/A&gt;"&lt;BR&gt;$urlsToTest["Sysinternals Home"] = "&lt;A href="http://www.microsoft.com/technet/sysinternals/default.mspx"&gt;http://www.microsoft.com/technet/sysinternals/default.mspx&lt;/A&gt;"&lt;BR&gt;$urlsToTest["Sysinternals Forum"] = "&lt;A href="http://forum.sysinternals.com/"&gt;http://forum.sysinternals.com&lt;/A&gt;"&lt;BR&gt;$urlsToTest["Sysinternals Blog"] = "&lt;A href="http://blogs.technet.com/sysinternals"&gt;http://blogs.technet.com/sysinternals&lt;/A&gt;"&lt;BR&gt;$urlsToTest["Sysinternals Downloads"] = "&lt;A href="http://download.sysinternals.com/Files/NtfsInfo.zip"&gt;http://download.sysinternals.com/Files/NtfsInfo.zip&lt;/A&gt;"&lt;/P&gt;
&lt;P&gt;$successCriteria = @{}&lt;BR&gt;$successCriteria["Sysinternals Redirect"] = "*Mark Russinovich*"&lt;BR&gt;$successCriteria["TechNet Redirect"] = "*Mark Russinovich*"&lt;BR&gt;$successCriteria["Sysinternals Home"] = "*Mark Russinovich*"&lt;BR&gt;$successCriteria["Sysinternals Forum"] = "*Sysinternals Utilities*"&lt;BR&gt;$successCriteria["Sysinternals Blog"] = "*Sysinternals Site Discussion*"&lt;BR&gt;$successCriteria["Sysinternals Downloads"] = "*ntfsinfo.exe*"&lt;/P&gt;
&lt;P&gt;$userAgent = "PowerShell User"&lt;BR&gt;$webClient = new-object System.Net.WebClient&lt;BR&gt;$webClient.Headers.Add("user-agent", $userAgent)&lt;/P&gt;
&lt;P&gt;foreach ($key in $urlsToTest.Keys) {&lt;BR&gt;&amp;nbsp;&amp;nbsp; $output = ""&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; $startTime = get-date&lt;BR&gt;&amp;nbsp;&amp;nbsp; $output = $webClient.DownloadString($urlsToTest[$key])&lt;BR&gt;&amp;nbsp;&amp;nbsp; $endTime = get-date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if ($output -like $successCriteria[$key]) {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $key + "`t`tSuccess`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($GArgs -eq "-log") {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $key + "`t`tSuccess`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds" &amp;gt;&amp;gt; WebSiteTest.log&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp; } else {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $key + "`t`tFail`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($GArgs -eq "-log") {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $key + "`t`tFail`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds" &amp;gt;&amp;gt; WebSiteTest.log&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($alert) {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $emailFrom = "&lt;A href="mailto:computer@nospam.com"&gt;computer@nospam.com&lt;/A&gt;"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $emailTo = $alert&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $subject = "URL Test Failure - " + $startTime&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $body = "URL Test Failure: " + $key + " (" + $urlsToTest[$key] + ") at " + $startTime&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $smtpServer = "somesmtpserver.nospam.com"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $smtp = new-object Net.Mail.SmtpClient($smtpServer)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $smtp.Send($emailFrom,$emailTo,$subject,$body)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/1810215/original.aspx" mce_src="http://blogs.technet.com/photos/otto/images/1810215/original.aspx"&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=1810231" width="1" height="1"&gt;</description></item><item><title>Quick and Dirty Software Inventory with PsInfo and PowerShell</title><link>http://blogs.technet.com/b/otto/archive/2007/03/04/quick-and-dirty-software-inventory-with-psinfo-and-powershell.aspx</link><pubDate>Sun, 04 Mar 2007 23:30:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:674021</guid><dc:creator>ottoh1</dc:creator><slash:comments>14</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/otto/rsscomments.aspx?WeblogPostID=674021</wfw:commentRss><comments>http://blogs.technet.com/b/otto/archive/2007/03/04/quick-and-dirty-software-inventory-with-psinfo-and-powershell.aspx#comments</comments><description>&lt;P&gt;&lt;A href="http://www.microsoft.com/technet/sysinternals/utilities/psinfo.mspx" mce_href="http://www.microsoft.com/technet/sysinternals/utilities/psinfo.mspx"&gt;PsInfo&lt;/A&gt; is great for gathering asset information from Windows computers, both locally and remotely. &lt;A href="http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx" mce_href="http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx"&gt;PowerShell&lt;/A&gt; is great for automation and cleaning up output (among other things) as well as working with database driven data.&lt;/P&gt;
&lt;P mce_keep="true"&gt;The following examples show how to gather an itemized list of the installed software on remote machines, process the data, then either display it to the screen or store it in a database. &lt;STRONG&gt;It's worth noting that PsInfo can also work on multiple remote computers from its native command line, or even read a list of computers from a file&lt;/STRONG&gt; (check out the &lt;A class="" href="http://www.microsoft.com/technet/sysinternals/utilities/psinfo.mspx" mce_href="http://www.microsoft.com/technet/sysinternals/utilities/psinfo.mspx"&gt;PsInfo&lt;/A&gt; site for more info). Since the final example seeks to show PsInfo in a database driven envoriment, PowerShell comes in very handy.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Note: In order for this example to work the necessary network connectivity and credentials will need to be in place.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Consider the following examples:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;1 - The output is merely displayed on the screen. With this method the output can be redirected to a file and imported into an application like Excel for further analysis or record keeping.&lt;/P&gt;
&lt;P mce_keep="true"&gt;2 - A database is used to drive the computers polled as well as store the output. The database table is very flat (one table) with 2 fields: 'Computer' and 'Software'. For large amounts of data, this will need to be normalized.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/674184/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;With the following output (imported into Excel):&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/674151/original.aspx" border=0&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;B&gt;Example 1: Standard Screen Output&lt;/B&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;The following PowerShell script gathers a software inventory from 3 remote computers ('happyhour', 'shaken', and 'extradry'). Presumably, your computer names will be different. After gathering and parsing the data, it's then displayed on the screen for all machines successfully queried.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Before running this script, test your connectivity and credentials with a single PsInfo command:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;PsInfo -s Applications &lt;/STRONG&gt;&lt;STRONG&gt;\\somecomputer&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;Example PowerShell script:&lt;/P&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;
&lt;BLOCKQUOTE&gt;$computersToQuery = ("happyhour","shaken","extradry")&lt;BR&gt;&lt;BR&gt;$softwareInventory = @{}&lt;BR&gt;foreach ($computer in $computersToQuery) {&lt;BR&gt;&amp;nbsp;&amp;nbsp; $psinfoOutput = ./psinfo.exe -s Applications \\$computer&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp; $foundSoftwareInventory = 0&lt;BR&gt;&amp;nbsp;&amp;nbsp; $computerName = ""&lt;BR&gt;&amp;nbsp;&amp;nbsp; foreach ($item in $psinfoOutput) {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($foundSoftwareInventory -eq 1) {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Force the results to a string&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove any single quotes which interfere with T-SQL statements&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Load the result into a hash whereby removing any duplicates&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [string]$softwareInventory[$computerName][$item.Replace("'","")] = ""&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($item -like "System information for *") {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $computerName = $item.Split("\")[2].TrimEnd(":")&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } elseif ($item -eq "Applications:") {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $foundSoftwareInventory = 1&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $softwareInventory[$computerName] = @{}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;foreach ($computer in $softwareInventory.Keys) {&lt;BR&gt;&amp;nbsp;&amp;nbsp; foreach ($softwareItem in $softwareInventory[$computer].Keys) {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $computer + ":" + $softwareItem&lt;BR&gt;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;BR&gt;&lt;/BLOCKQUOTE&gt;&lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;Your output should look something like:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;B&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/674025/original.aspx" border=0&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Example 2: Save Output to a Database&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;This example is additive to the first in that it adds the following 3 items:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;1- Pulls the list of computer to query from a database table&lt;/LI&gt;
&lt;LI&gt;2- Adds the current data and time to the result&lt;/LI&gt;
&lt;LI&gt;3- Records the audit results into a database&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;The following is the database schema for this example:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/674022/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Example PowerShell script:&lt;/P&gt;&lt;SPAN style="FONT-FAMILY: Courier"&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;# Open the database connection&lt;BR&gt;$dbConn = new-object System.Data.SqlClient.SqlConnection "server=kcdb;database=Inventory;Integrated Security=sspi"&lt;BR&gt;$dbConn.Open()&lt;BR&gt;$sqlQuery = $dbConn.CreateCommand()&lt;BR&gt;&lt;BR&gt;# Get all known computers&lt;BR&gt;$sqlQuery.CommandText = "select * from Inventory..Computers"&lt;BR&gt;$reader = $sqlQuery.ExecuteReader()&lt;BR&gt;$computersToQuery = @()&lt;BR&gt;while ($reader.Read()) {&lt;BR&gt;&amp;nbsp;&amp;nbsp; $computersToQuery += $reader["Computer"]&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;# Close the database connection&lt;BR&gt;$dbConn.Close()&lt;BR&gt;&lt;BR&gt;$softwareInventory = @{}&lt;BR&gt;foreach ($computer in $computersToQuery) {&lt;BR&gt;&amp;nbsp;&amp;nbsp; $psinfoOutput = ./psinfo.exe -s Applications \\$computer&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp; $foundSoftwareInventory = 0&lt;BR&gt;&amp;nbsp;&amp;nbsp; $computerName = ""&lt;BR&gt;&amp;nbsp;&amp;nbsp; foreach ($item in $psinfoOutput) {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($foundSoftwareInventory -eq 1) {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Force the results to a string&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove any single quotes which interfere with T-SQL statements&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Load the result into a hash whereby removing any duplicates&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [string]$softwareInventory[$computerName][$item.Replace("'","")] = ""&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($item -like "System information for *") {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $computerName = $item.Split("\")[2].TrimEnd(":")&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } elseif ($item -eq "Applications:") {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $foundSoftwareInventory = 1&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $softwareInventory[$computerName] = @{}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;$dbConn = new-object System.Data.SqlClient.SqlConnection "server=kcdb;database=Inventory;Integrated Security=sspi"&lt;BR&gt;$dbConn.Open()&lt;BR&gt;$sqlQuery = $dbConn.CreateCommand()&lt;BR&gt;&lt;BR&gt;foreach ($computer in $softwareInventory.Keys) {&lt;BR&gt;&amp;nbsp;&amp;nbsp; foreach ($softwareItem in $softwareInventory[$computer].Keys) {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Loading-" + $computer + ":" + $softwareItem&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Try an Insert than an Update&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trap {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $sqlQuery.CommandText = "update Inventory..SoftwareInventory set AuditDate = getdate() where&amp;nbsp; Computer = '" + $computer + "' and Software = '" + $softwareItem + "'"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $result = $sqlQuery.ExecuteNonQuery()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; continue&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $sqlQuery.CommandText = "insert into Inventory..SoftwareInventory (Computer,Software,AuditDate) values ('" + $computer + "','" + $softwareItem + "',getdate())"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $result = $sqlQuery.ExecuteNonQuery()&lt;BR&gt;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;$dbConn.Close()&lt;BR&gt;&lt;/BLOCKQUOTE&gt;&lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&lt;B&gt;For more information:&lt;/B&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Get PsInfo bits and info: &lt;A href="http://www.microsoft.com/technet/sysinternals/utilities/psinfo.mspx" mce_href="http://www.microsoft.com/technet/sysinternals/utilities/psinfo.mspx"&gt;http://www.microsoft.com/technet/sysinternals/utilities/psinfo.mspx&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Get PowerShell bits and info: &lt;A href="http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx" mce_href="http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx"&gt;http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;The PowerShell blog: &lt;A href="http://blogs.msdn.com/powershell/"&gt;http://blogs.msdn.com/powershell/&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=674021" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/b/otto/archive/tags/Asset/">Asset</category><category domain="http://blogs.technet.com/b/otto/archive/tags/Inventory/">Inventory</category><category domain="http://blogs.technet.com/b/otto/archive/tags/PsInfo/">PsInfo</category><category domain="http://blogs.technet.com/b/otto/archive/tags/PowerShell/">PowerShell</category></item><item><title>Automate E-Mail Alerts with Windows Vista</title><link>http://blogs.technet.com/b/otto/archive/2007/03/01/e-mail-alerts-with-windows-vista.aspx</link><pubDate>Thu, 01 Mar 2007 22:24:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:667250</guid><dc:creator>ottoh1</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/otto/rsscomments.aspx?WeblogPostID=667250</wfw:commentRss><comments>http://blogs.technet.com/b/otto/archive/2007/03/01/e-mail-alerts-with-windows-vista.aspx#comments</comments><description>&lt;P&gt;The Windows&amp;nbsp;Task Scheduler as been completely re-written for Windows Vista&amp;nbsp;to be a very powerful automation tool. The Task Scheduler now has the ability to launch tasks from a wide variety of useful triggers rather than being limited to the standard time based trigger.&amp;nbsp;One of the most powerful triggers is the 'On an event' trigger and this example can easly be extended to leverage it for even more alerting options.&amp;nbsp;In addition, tasks can now&amp;nbsp;execute notifications (message box and e-mail)&amp;nbsp;where they were previously limited to the&amp;nbsp;standard command line action.&lt;/P&gt;
&lt;P&gt;This example sets up a simple e-mail alert using Task Scheduler and PowerShell which sends an e-mail every time somebody connects to (login, remote desktop, or unlocks) the local computer. This might be useful for auditing access to critical systems in a data center.&lt;/P&gt;
&lt;P&gt;Consider the 2 options for sending an e-mail alert from the new Task Scheduler:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/667244/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;1 - E-Mail Action using PowerShell:&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Since this PowerShell script uses the SmtpClient object in Windows, it has more flexibility when dealing with SMTP server authentication requirements. This example sends the alert e-mail through an SMTP server that does not require authentication.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;2- E-Mail directly through a Task Scheduler action:&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Although the new Task Scheduler supports direct e-mail actions via SMTP, it is limited to fairly specific scenarios. It will only work if authentication is required by the SMTP server &lt;STRONG&gt;and&lt;/STRONG&gt; the credentials used for the SMTP authentication need to be the same credentials used to run the task. For these reasons, this example will focus on option #1.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Step 1:&lt;/STRONG&gt; Open 'Task Scheduler' and create a task to run whether the user is logged on or not&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/667240/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Step 2:&lt;/STRONG&gt; Create 3 triggers ('At log on', 'On connection to user session', 'On workstation unlock'). Notice that an 'On event' trigger may be used instead to track a wide variety of state changes in a computer.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/667243/original.aspx" border=0&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Step 3:&lt;/STRONG&gt; Create the action to run the PowerShell e-mail script&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/667245/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Step 4:&lt;/STRONG&gt; Create the PowerShell script (for this example it's called 'ConnectionAlert.ps1')&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;$emailFrom = "computer@nospam.com"&lt;BR&gt;$emailTo = "somebody@nospam.com"&lt;BR&gt;$subject = "Connection Alert"&lt;BR&gt;$body = "Somebody has connected to the computer."&lt;BR&gt;$smtpServer = "somesmtpserver.nospam.com"&lt;BR&gt;$smtp = new-object Net.Mail.SmtpClient($smtpServer)&lt;BR&gt;$smtp.Send($emailFrom,$emailTo,$subject,$body)&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Step 5:&lt;/STRONG&gt; Test the PowerShell Script&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;C:\&amp;gt; PowerShell ./ConnectionAlert.ps1&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Step 6:&lt;/STRONG&gt; Test the Task by running it directly from the Task Scheduler, then by locking and unlocking the computer.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;For more information:&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Windows Vista Task Scheduler: &lt;A href="http://msdn2.microsoft.com/en-us/library/aa383614.aspx"&gt;http://msdn2.microsoft.com/en-us/library/aa383614.aspx&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Get PowerShell bits and information: &lt;A class="" href="http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx" mce_href="http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx"&gt;http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=667250" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/b/otto/archive/tags/Alerts/">Alerts</category><category domain="http://blogs.technet.com/b/otto/archive/tags/Automation/">Automation</category><category domain="http://blogs.technet.com/b/otto/archive/tags/Vista/">Vista</category><category domain="http://blogs.technet.com/b/otto/archive/tags/Task+Scheduler/">Task Scheduler</category></item><item><title>WS-Man Ping Test</title><link>http://blogs.technet.com/b/otto/archive/2007/02/21/ws-man-ping-test.aspx</link><pubDate>Wed, 21 Feb 2007 22:24:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:656815</guid><dc:creator>ottoh1</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/otto/rsscomments.aspx?WeblogPostID=656815</wfw:commentRss><comments>http://blogs.technet.com/b/otto/archive/2007/02/21/ws-man-ping-test.aspx#comments</comments><description>&lt;P&gt;WS-Man (Windows Remote Management) is a new protocol and framework&amp;nbsp;first delivered in Windows 2003 R2 and is more prevalent in Windows Vista and beyond.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's an easy way to test WS-Man reachability that is&amp;nbsp;similar to the network ping concept by testing both the network connectivity as well as the end-point service. The main component that is &lt;STRONG&gt;not&lt;/STRONG&gt; tested by 'winrm id...' is security (authentication). The following examples use an end-point system called 'wsman.msft.net' which may or may not exist. At the time of this posting, it was active.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/656828/original.aspx" border=0 mce_src="http://blogs.technet.com/photos/otto/images/656828/original.aspx"&gt;&lt;/P&gt;
&lt;P&gt;Consider the 2 basic network configurations.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1 - Direct connectivity:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Direct connectivity implies that there are no intermediate network proxies or that the intermediate network devices attempt to be transparent. Transparent devices include Network Address Translators (NATs), routers, etc. In the direct connectivity model, the following WS-Man Id command should work as is, therefore successfully testing the end point's WS-Man service availability.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;winrm id -auth:none -remote:wsman.msft.net&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;2- Indirect connectivity:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;When there is a non-transparent network device like a proxy between both end points, WinRM uses the proxy identified in&amp;nbsp;the winhttp agent&amp;nbsp;configuration (this is different than the proxy defined in IE). Much like IE needs to be aware of proxies in the environment for Internet or external connectivity, so does WinRM. This can be accomplished by&amp;nbsp;using Net Shell to configure&amp;nbsp;winhttp to route through a proxy&amp;nbsp;as follows (run from an elevated command prompt).&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;netsh winhttp set proxy proxy-server=&lt;/STRONG&gt;&lt;STRONG&gt;http://someproxy/&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now the following WS-Man ping should work.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;winrm id -auth:none -remote:wsman.msft.net&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/656829/original.aspx" border=0 mce_src="http://blogs.technet.com/photos/otto/images/656829/original.aspx"&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=656815" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/b/otto/archive/tags/WS_2D00_Man/">WS-Man</category><category domain="http://blogs.technet.com/b/otto/archive/tags/Ping/">Ping</category><category domain="http://blogs.technet.com/b/otto/archive/tags/Windows+Remote+Management/">Windows Remote Management</category><category domain="http://blogs.technet.com/b/otto/archive/tags/WinRM/">WinRM</category></item><item><title>A Few Good Vista WS-Man (WinRM) Commands</title><link>http://blogs.technet.com/b/otto/archive/2007/02/09/sample-vista-ws-man-winrm-commands.aspx</link><pubDate>Sat, 10 Feb 2007 02:57:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:632975</guid><dc:creator>ottoh1</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/otto/rsscomments.aspx?WeblogPostID=632975</wfw:commentRss><comments>http://blogs.technet.com/b/otto/archive/2007/02/09/sample-vista-ws-man-winrm-commands.aspx#comments</comments><description>&lt;P&gt;In Vista, a lot of instrumentation, configuration, and utilization information is exposed via WS-Man. Vista WS-Man (aka: WS-Management, Windows Remote Management, and WinRM) incorporates&amp;nbsp;many features, but I like to think of it as the management protocol/framework of the future (look out SNMP!). What makes WS-Man so great is the fact that it's all standards based, rides on HTTP/HTTPS (very firewall/NAT friendly), and packages its data in SOAP/XML packets (easy to shove into a database or use with a script).&lt;/P&gt;
&lt;P&gt;Out of the box; Vista WS-Man exposes WMI information as well as Windows Remote Shell capabilities. What this means is that with WS-Man it's much easier to get instrumentation from remote machines as well as use that info in scripts.&lt;/P&gt;
&lt;P&gt;Here are some sample commands to play with. If you cannot get the ‘Test WS-Man...' step to work, none of the steps following will work either (you're probably not using the right credentials to access the remote machine). One more caveat, the remote commands work best on domain joined machines. For workgroup machines, the WinRM service needs additional configuration.&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=0 width=685 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P align=center&gt;&lt;B&gt;Description&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P align=center&gt;&lt;B&gt;Command&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=685 colSpan=2&gt;
&lt;P align=center&gt;&lt;I&gt;Run from an &lt;B&gt;Elevated&lt;/B&gt; Command prompt&lt;/I&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Quickly configure the WS-Man service&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;winrm QuickConfig&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Quickly delete the WS-Man listener&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;winrm invoke Restore winrm/Config @{}&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=685 colSpan=2&gt;
&lt;P align=center&gt;&lt;I&gt;Run from an &lt;B&gt;standard&lt;/B&gt; Command prompt&lt;/I&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Display your machine's basic hardware info&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;winrm enumerate wmicimv2/Win32_ComputerSystem&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Display your operating system properties&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;winrm get wmicimv2/Win32_OperatingSystem&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Output your OS info in XML&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;winrm get wmicimv2/Win32_OperatingSystem -format:pretty&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Ping WS-Man on a remote machine&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;winrm id -auth:none -remote:&amp;lt;some machine&amp;gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Test WS-Man access to a remote machine**&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;winrm id -remote:&amp;lt;some machine&amp;gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Grab a remote machine's WS-Man config&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;winrm get winrm/Config -r:&amp;lt;some machine&amp;gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Grab a remote machine's CPU load&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;winrm g wmicimv2/Win32_Processor?DeviceID=CPU0 -fragment:LoadPercentage -r:&amp;lt;some computer&amp;gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Grab a remote machine's free memory&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;winrm g wmicimv2/Win32_OperatingSystem -fragment:FreePhysicalMemory -r:&amp;lt;some computer&amp;gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Stop a service on a remote machine&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;winrm invoke stopservice wmicimv2/Win32_Service?name=w32time -r:&amp;lt;some computer&amp;gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Start a service on a remote machine&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;winrm invoke startservice wmicimv2/Win32_Service?name=w32time -r:&amp;lt;some computer&amp;gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Reboot a remote machine&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;winrm invoke reboot wmicimv2/Win32_OperatingSystem -r:&amp;lt;some computer&amp;gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Run a command on a remote machine (this uses winr&lt;B&gt;S&lt;/B&gt;, not winr&lt;B&gt;M&lt;/B&gt;)&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;winrs -r:&amp;lt;some computer&amp;gt; ipconfig /all&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=685 colSpan=2&gt;
&lt;P align=center&gt;&lt;I&gt;Run from &lt;B&gt;PowerShell&lt;/B&gt;&lt;/I&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Use PowerShell to grab the WS-Man Win32_OperatingSystem XML output&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;[xml]$osInfo = winrm get wmicimv2/Win32_OperatingSystem /format:pretty&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Display the OS version property&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;$osInfo.Win32_OperatingSystem.Version&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Display the last boot time&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;$osInfo.Win32_OperatingSystem.LastBootupTime.DateTime&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Put free memory metric into an XML variable&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;[xml]$freemem = cmd /c "winrm get wmicimv2/Win32_OperatingSystem -fragment:FreePhysicalMemory -f:pretty -r:&amp;lt;some computer&amp;gt;"&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=277&gt;
&lt;P&gt;Display the free memory value&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=408&gt;
&lt;P&gt;$freemem.XMLFragment.FreePhysicalMemory&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;**Note: This step verifies that you have good connectivity to the remote machine, WS-Man is running and properly configured on the remote machine, AND you have the correct permissions to fully leverage WS-Man on the remote machine. If this step fails, it's probably a permissions issue.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Details:&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;WS-Man (WinRM) Architecture&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;The following diagram shows a high-level overview of the WS-Man (WinRM) architecture. In the diagram the 'Client' is querying the 'Server' for WS-Man information. Note that HTTP.sys and WinHTTP support the HTTP(s) transport for WS-Man, not IIS. In addition, IIS (or another web publishing service) can co-exist with WS-Man and share port 80.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/641897/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Quickly configure the WS-Man service&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Remember, this needs to be run from an 'Elevated' Command Prompt.&lt;/P&gt;
&lt;P&gt;As you can see, this simple command does quite a bit. Please note every modification (hightlighted) since this might increase the attack surface of your computer. For example, Quick Config configures a listener that accepts connections from every network interface. This is probably not ideal for edge machines that connect to unsecure networks (like the Internet). In addition, this command only needs to be run once.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/641894/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Quickly delete the WS-Man listener&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Although this command only deletes all WinRM listeners, it effectively turns off any WS-Man communication to a machine.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/641895/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Display your machine's basic hardware info and operating system properties&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Win32_ComputerSystem and Win32_OperatingSystem are common WMI classes and useful for asset information and configuration information as well as some utilization metrics.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/641890/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Output your OS info in XML&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;XML output makes the data much easier for storing in a database or dealing with programmatically (like with a script). PowerShell makes this that much easier since it works VERY well with XML (see below for a sample PowerShell script).&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/641898/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Ping WS-Man on a remote machine and test authorization credentials&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Testing WS-Man on a remote machine is very useful in troubleshooting lots of connectivity and configuration issues. When pinging WS-Man without 'auth', it allows for the testing of the connectivity and basic service configuration. Using the 'auth' parameter tests the necessary authorization. Generally the credentials need to be in the 'Administrators' group for 'auth' to work. In this case no credentials are provided so the current credentials are used (this can be over-ridden). Notice that the OS version is included when successfully using 'auth' to test WS-Man.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/641893/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Grab a remote machine's WS-Man config&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Successfully completing this step pretty much insures that one has complete access to WS-Man on the remote computer.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Grab a remote machine's CPU load, free memory, and restart a service&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;WS-Man allows for gathering WMI properties (reading and writing although we're only reading in this example) as well as invoking methods (starting and stopping a service; as well as rebooting!). Notice the minimal return code for the invoke commands (0 = success).&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/641892/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Run a command on a remote machine (this uses winrS, not winrM)&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;WinRS is another utility that leverages WS-Man. WinRS allows for the execution of local, non-interactive command-line commands on a remote machine and returns the output. In other words, if the command can be run at the CMD prompt without any required input and it only accesses local resource (no network shares for example), then it will most likely work. There are ways to get around the 'local resource' issue, but that is out of scope for this blog.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/641896/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Use PowerShell to grab instrumentation via WS-Man&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;PowerShell is great for consuming data from WS-Man since it works very well with XML. Notice that in the following example it's easy to 'surf' an object in PowerShell. In this case the XML object 'osInfo' is displayed on its own, and then expanded to the 'Win32_OperatingSystem' branch.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG src="http://blogs.technet.com/photos/otto/images/641889/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;A simple PowerShell script&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;The following script shows how easy it is to automate the collection of WS-Man information using PowerShell.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;$machines = ("machine1","machine2","machine3")&lt;BR&gt;foreach ($machine in $machines) {&lt;BR&gt;&amp;nbsp;&amp;nbsp; [xml]$osInfo = winrm get wmicimv2/Win32_OperatingSystem /format:pretty /r:$machine&lt;BR&gt;&amp;nbsp;&amp;nbsp; $machine + ": " + $osInfo.Win32_OperatingSystem.LastBootupTime.DateTime&lt;BR&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;B&gt;More Info&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;For more information on WS-Man, please see the following articles:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Microsoft: &lt;A href="http://msdn2.microsoft.com/en-us/library/aa384291.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/aa384291.aspx"&gt;About Windows Remote Management&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Microsoft: &lt;A href="http://msdn2.microsoft.com/en-us/library/aa384462.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/aa384462.aspx"&gt;Using Windows Remote Management&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Microsoft: &lt;A href="http://msdn2.microsoft.com/en-us/library/aa384466.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/aa384466.aspx"&gt;Windows Remote Management Reference&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Sun: &lt;A href="https://wiseman.dev.java.net/" mce_href="https://wiseman.dev.java.net/"&gt;A Java Implementation of WS-Man&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;SourceForge: &lt;A href="http://sourceforge.net/projects/openwsman/" mce_href="http://sourceforge.net/projects/openwsman/"&gt;Open WS-Man Project&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;DMTF (PDF): &lt;A href="http://www.dmtf.org/standards/published_documents/WS-ManFactSheet.pdf" mce_href="http://www.dmtf.org/standards/published_documents/WS-ManFactSheet.pdf"&gt;WS-Management Fact Sheet&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;DMTF (PDF): &lt;A href="http://www.dmtf.org/standards/published_documents/DSP0226.pdf" mce_href="http://www.dmtf.org/standards/published_documents/DSP0226.pdf"&gt;WS-Management Standard Document&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=632975" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/b/otto/archive/tags/WS_2D00_Man/">WS-Man</category><category domain="http://blogs.technet.com/b/otto/archive/tags/Windows+Remote+Management/">Windows Remote Management</category><category domain="http://blogs.technet.com/b/otto/archive/tags/WinRM/">WinRM</category><category domain="http://blogs.technet.com/b/otto/archive/tags/WS_2D00_Shell/">WS-Shell</category><category domain="http://blogs.technet.com/b/otto/archive/tags/WS_2D00_Management/">WS-Management</category></item></channel></rss>