{"id":16281,"date":"2010-12-08T00:01:00","date_gmt":"2010-12-08T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2010\/12\/08\/use-a-powershell-module-to-work-with-wmi-permanent-events\/"},"modified":"2010-12-08T00:01:00","modified_gmt":"2010-12-08T00:01:00","slug":"use-a-powershell-module-to-work-with-wmi-permanent-events","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-a-powershell-module-to-work-with-wmi-permanent-events\/","title":{"rendered":"Use a PowerShell Module to Work with WMI Permanent Events"},"content":{"rendered":"<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\">Summary:<\/span><\/b><span style=\"font-size: 10pt\"> Learn how to use a Windows PowerShell module to work with WMI permanent events.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\"><span style=\"font-size: 10pt\"><span style=\"font-size: 10pt\"><span style=\"font-size: 10pt\"><span style=\"font-size: 10pt\"><span style=\"font-size: 10pt\"><span style=\"font-size: 10pt\"><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Question\" border=\"0\" title=\"Hey, Scripting Guy! Question\"><\/span><\/span><\/span><\/span><\/span><\/span>Hey, Scripting Guy! Your posts this week on permanent event consumers have been really cool. I am wondering, if they are so useful, why there is not a Windows PowerShell cmdlet to allow one to interact with them?<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">&#8212; ST<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\"><span style=\"font-size: 10pt\"><span style=\"font-size: 10pt\"><span style=\"font-size: 10pt\"><span style=\"font-size: 10pt\"><span style=\"font-size: 10pt\"><span style=\"font-size: 10pt\"><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Answer\" border=\"0\" title=\"Hey, Scripting Guy! Answer\"><\/span><\/span><\/span><\/span><\/span><\/span>Hello ST, Microsoft Scripting Guy Ed Wilson here. As a matter of fact, Trevor Sullivan was thinking the same thing. One of the great things about Windows PowerShell is that if you do not like it, you can change it. Another great thing is that if something is missing, you can frequently write your own. With <a href=\"http:\/\/support.microsoft.com\/kb\/968929\"><span style=\"color: #0000ff\">Windows PowerShell 2.0<\/span><\/a> modules, the code that you write (or find) can be adapted to behave in the same manner as a Windows PowerShell cmdlet. I will let Trevor introduce himself and his module. Take it away.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\"><\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\"><\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\">Background<\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">Hello, my name is Trevor Sullivan. I&rsquo;ve been working on a Windows PowerShell module recently that makes working with Windows Management Instrumentation (WMI) permanent event registrations much easier! The name of this module is <b>PowerEvents<\/b> &mdash; appropriately named to combine Windows PowerShell and WMI eventing. You can download this module for free, from <a href=\"http:\/\/powerevents.codeplex.com\/\"><span style=\"color: #0000ff\">http:\/\/powerevents.codeplex.com<\/span><\/a>, and there is ample documentation in the form of a PDF document, YouTube videos, and the CodePlex.com wiki.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">There were several reasons that I began developing this module. First and foremost, I wanted to make working with WMI permanent event registrations easy from Windows PowerShell. Second, I have noticed over time that many people seem interested in responding to system-level events, by running some Windows PowerShell code, a VBScript, or an executable. Occasionally, I&rsquo;ll come across <a href=\"http:\/\/social.technet.microsoft.com\/Forums\/en-US\/ITCG\/threads\"><span style=\"color: #0000ff\">forum<\/span><\/a> posts, or e-mails on a mailing list, where someone wants something to occur in response to an event. Usually the person knows what they want to respond to, and what they want to occur, but perhaps are unaware of WMI events. To summarize, the secondary reason I developed this module, was to help spread the knowledge of WMI events, and to help make them easier for people to understand. Perusing through developer documentation on MSDN is not always what people would consider &ldquo;easy.&rdquo;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">To satisfy the requirements of these requests, it is sometimes sufficient to use temporary event registrations in WMI. In Windows PowerShell, this is made quite easy using the <b>Register-WmiEvent<\/b> cmdlet. This cmdlet is included in Windows PowerShell 2.0. It is also relatively easy to use temporary event registrations in a VBScript or <a href=\"http:\/\/www.microsoft.com\/express\/vcsharp\/Default.aspx\"><span style=\"color: #0000ff\">C#<\/span><\/a> program. Nevertheless, you must write a fair amount of code to get these working. What is arguably the largest downside to using temporary event registrations, is that they only survive as long as the program (or, process) hosting them (eg. cscript.exe, if you are using a VBScript). <\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">Unlike temporary event registrations, permanent event registrations are created purely inside WMI. Because the WMI process (wmiprvse.exe) is running constantly as a background service, these event registrations are always in effect, unless you explicitly remove them. Be aware that this does not replace an enterprise monitoring solution, but with some creativity on your part, you can easily automate your IT environment. In fact, you could even use the same concepts to automate event-driven actions on your home computers!<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\"><\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\"><\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\">About PowerEvents<\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">As previously discussed, <b>PowerEvents<\/b> intends to make working with WMI permanent event registrations easy. To that end, it provides several Windows PowerShell advanced functions to create the three necessary WMI objects, to create an end-to-end event Registration:<\/span><\/p>\n<ul>\n<li>\n<div class=\"MsoListParagraphCxSpFirst\" style=\"line-height: 115%;text-indent: -0.25in;margin: 0in 0in 10pt\"><b><span style=\"line-height: 115%;font-size: 10pt\">New-WmiEventFilter<\/span><\/b><span style=\"line-height: 115%;font-size: 10pt\"> &ndash; Creates a WMI event filter, defining the events you want to respond to.<\/span><\/div>\n<\/li>\n<li>\n<div class=\"MsoListParagraphCxSpMiddle\" style=\"line-height: 115%;text-indent: -0.25in;margin: 0in 0in 10pt\"><b><span style=\"line-height: 115%;font-size: 10pt\">New-WmiEventConsumer<\/span><\/b><span style=\"line-height: 115%;font-size: 10pt\"> &ndash; Create a consumer, or responder, for the events defined in an event filter.<\/span><\/div>\n<\/li>\n<li>\n<div class=\"MsoListParagraphCxSpLast\" style=\"line-height: 115%;text-indent: -0.25in;margin: 0in 0in 10pt\"><b><span style=\"line-height: 115%;font-size: 10pt\">New-WmiFilterToConsumerBinding<\/span><\/b><span style=\"line-height: 115%;font-size: 10pt\"> &ndash; Literally what the name says, a binding between a WMI event filter and a consumer.<\/span><\/div>\n<\/li>\n<\/ul>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">With a simple three lines of Windows PowerShell, you can create a filter, a consumer, and the binding between the two. Because these are advanced functions, you can use tab completion for the parameter names. You can also get help on the functions and their parameters by using <b>Get-Help<\/b> <i>&lt;FunctionName&gt;<\/i> or <b>Get-Help<\/b> <i>&lt;FunctionName&gt; -Full<\/i>.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\"><\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\">Filters<\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">The first step to creating a permanent event registration is coming up with the events that you want to capture! This should be easy, since it is usually the first thing on most people&rsquo;s minds. You can monitor things such as:<\/span><\/p>\n<ul>\n<li>\n<div class=\"MsoListParagraphCxSpFirst\" style=\"line-height: 115%;text-indent: -0.25in;margin: 0in 0in 10pt\"><span style=\"line-height: 115%;font-size: 10pt\">User profile loaded \/ unloaded<\/span><\/div>\n<\/li>\n<li>\n<div class=\"MsoListParagraphCxSpMiddle\" style=\"line-height: 115%;text-indent: -0.25in;margin: 0in 0in 10pt\"><span style=\"line-height: 115%;font-size: 10pt\">USB flash drive (UFD) plugged in or removed<\/span><\/div>\n<\/li>\n<li>\n<div class=\"MsoListParagraphCxSpMiddle\" style=\"line-height: 115%;text-indent: -0.25in;margin: 0in 0in 10pt\"><span style=\"line-height: 115%;font-size: 10pt\">Partition is resized (shrunk or expanded)<\/span><\/div>\n<\/li>\n<li>\n<div class=\"MsoListParagraphCxSpMiddle\" style=\"line-height: 115%;text-indent: -0.25in;margin: 0in 0in 10pt\"><span style=\"line-height: 115%;font-size: 10pt\">Page file utilization exceeds a certain amount<\/span><\/div>\n<\/li>\n<li>\n<div class=\"MsoListParagraphCxSpMiddle\" style=\"line-height: 115%;text-indent: -0.25in;margin: 0in 0in 10pt\"><span style=\"line-height: 115%;font-size: 10pt\">Process is created or terminated<\/span><\/div>\n<\/li>\n<li>\n<div class=\"MsoListParagraphCxSpMiddle\" style=\"line-height: 115%;text-indent: -0.25in;margin: 0in 0in 10pt\"><span style=\"line-height: 115%;font-size: 10pt\">Print job is created or completed<\/span><\/div>\n<\/li>\n<li>\n<div class=\"MsoListParagraphCxSpLast\" style=\"line-height: 115%;text-indent: -0.25in;margin: 0in 0in 10pt\"><span style=\"line-height: 115%;font-family: Symbol;font-size: 10pt\"><span><span style=\"font: 7pt 'Times New Roman'\">&nbsp;<\/span><\/span><\/span><b><span style=\"line-height: 115%;font-size: 10pt\">&hellip; and lots, lots more!<\/span><\/b><\/div>\n<\/li>\n<\/ul>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">You use the <b>New-WmiEventFilter<\/b> function to create an event filter, makes sense, right? Remember that with Windows PowerShell, it&rsquo;s think, type, get. All that you have to do is give a helpful name to the event filter (using the <i>-Name<\/i> parameter), and provide the WMI Query Language (WQL) event filter that you want to use. Assign the output of the <b>New-WmiEventFilter<\/b> function to a Windows PowerShell variable, because you will need it later to create the Filter\/Consumer binding.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">Here is an example of creating a WMI event filter:<\/span><\/p>\n<p class=\"CodeBlock\" style=\"margin: 4pt 0in 7pt 0.5in\"><span style=\"font-size: 10pt\"><span style=\"font-family: Lucida Sans Typewriter\">New-WmiEventFilter <i>-Name<\/i> UserProfileLoaded <i>-Query<\/i> &#8220;select * from __InstanceModificationEvent within 2 where TargetInstance ISA &#8216;Win32_UserProfile&#8217; and TargetInstance.Loaded &lt;&gt; PreviousInstance.Loaded and TargetInstance.Loaded = TRUE&#8221;<\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"margin: 4pt 0in 7pt\"><span style=\"font-size: 10pt\"><span style=\"font-family: Lucida Sans Typewriter\">&nbsp;<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">As you can see, we gave the filter a useful name that describes its purpose. We then passed our event query to the <i>&ndash;Query<\/i> parameter. That&rsquo;s it!<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">Now that you have created an event filter, the next step is to create an event consumer to respond to the events!<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\"><\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\"><\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\">Consumers<\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\">New-WmiEventConsumer<\/span><\/b><span style=\"font-size: 10pt\"> is the most complex of the three functions, but don&rsquo;t worry, it&rsquo;s simple. Because it wraps the functionality of five event consumers included in Windows, there are a large number of parameters. Do not get overwhelmed by all the parameters, because in most cases, you will only have to specify a couple of them. The <i>ConsumerType<\/i> and <i>Name<\/i> parameters are most important, and are common to all consumer types. Beyond these two parameters, the others will depend on the consumer type that you want to use.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">There are five consumer types that you can select from: SMTP, LogFile, EventLog, Script, and CommandLine. For most purposes, the Script and CommandLine consumers will probably be the most useful to you, because they are the most flexible in how you respond to an event.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">Here is an example of creating a script consumer:<\/span><\/p>\n<p class=\"CodeBlock\" style=\"margin: 4pt 0in 7pt 0.5in\"><span style=\"font-size: 10pt\"><span style=\"font-family: Lucida Sans Typewriter\">$VBcode = @&#8221;<\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"margin: 4pt 0in 7pt 0.5in\"><span style=\"font-size: 10pt\"><span style=\"font-family: Lucida Sans Typewriter\">set fso = CreateObject(&#8220;Scripting.FileSystemOb\nject&#8221;)<\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"margin: 4pt 0in 7pt 0.5in\"><span style=\"font-size: 10pt\"><span style=\"font-family: Lucida Sans Typewriter\">set LogFile = fso.OpenTextFile(&#8220;c:Printer.log&#8221;, 8, true)<\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"margin: 4pt 0in 7pt 0.5in\"><span style=\"font-size: 10pt\"><span style=\"font-family: Lucida Sans Typewriter\">call LogFile.WriteLine(Date() &amp; &#8221; &#8221; &amp; Time() &amp; &#8220;: Print job created&#8221;)<\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"margin: 4pt 0in 7pt 0.5in\"><span style=\"font-size: 10pt\"><span style=\"font-family: Lucida Sans Typewriter\">&#8220;@<\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"margin: 4pt 0in 7pt 0.5in\"><span style=\"font-size: 10pt\"><span style=\"font-family: Lucida Sans Typewriter\">New-WmiEventConsumer <i>-Name<\/i> PrintJobCreated <i>-ConsumerType<\/i> Script <i>-ScriptText<\/i> $VBcode<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">The VBscript we want to run is contained within a Windows PowerShell here-string, and then we call <b>New-WmiEventConsumer<\/b>, give it a useful name, tell it we are creating a Script consumer type, and then pass in the $VBcode we defined.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\"><\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\"><\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\">Bindings<\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">WMI event filters and consumers are completely independent entities from one another unless you create a binding between them. The binding initiates the flow of events through the WMI eventing subsystem, and allows you to specify exactly what action should occur in response to an event coming from an event filter.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">The <b>New-WmiFilterToConsumerBinding<\/b> function allows you to create the binding between a filter and a consumer. It has two main parameters, <i>&ndash;Filter<\/i> and <i>&ndash;Consumer<\/i>. To use this function, pass a reference to an event filter to <i>&ndash;Filter<\/i>, and a reference to a consumer to <i>&ndash;Consumer<\/i>.<\/span><\/p>\n<p class=\"CodeBlock\" style=\"margin: 4pt 0in 7pt 0.5in\"><span style=\"font-size: 10pt\"><span style=\"font-family: Lucida Sans Typewriter\">$MyConsumer = New-WmiEventConsumer &hellip; &hellip; &hellip;<\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"margin: 4pt 0in 7pt 0.5in\"><span style=\"font-size: 10pt\"><span style=\"font-family: Lucida Sans Typewriter\">$MyFilter = New-WmiEventFilter &hellip; &hellip; &hellip;<\/span><\/span><\/p>\n<p class=\"CodeBlock\" style=\"margin: 4pt 0in 7pt 0.5in\"><span style=\"font-size: 10pt\"><span style=\"font-family: Lucida Sans Typewriter\">New-WmiFilterToConsumerBinding &ndash;Filter $MyFilter &ndash;Consumer $MyConsumer<\/span><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">Here, we create a consumer, and store it in a variable, then create a filter and store it in a variable, and finally create the binding between the two using <b>New-WmiFilterToConsumerBinding<\/b>.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\"><\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\"><\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\">Conclusion<\/span><\/b><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">Today, we introduced the <b>PowerEvents<\/b> module for Windows PowerShell, and talked about the three main functions that it contains. In tomorrow&rsquo;s blog post, we will examine some specific examples of using the <b>PowerEvents<\/b> module to create permanent WMI event registrations. Thanks for reading!<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\"><\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">ST, that is all there is to using the Windows PowerShell event module. Permanent event consumer week will continue tomorrow when Trevor will talk about how to incorporate his module. <\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">I invite you to follow me on <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguystwitter\"><span style=\"color: #0000ff\">Twitter<\/span><\/a> or <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\"><span style=\"color: #0000ff\">Facebook<\/span><\/a>. If you have any questions, send email to me at <a target=\"_blank\" href=\"http:\/\/blogs.technet.commailto:scripter@microsoft.com\"><span style=\"color: #0000ff\">scripter@microsoft.com<\/span><\/a> or post them on the <a href=\"http:\/\/social.technet.microsoft.com\/Forums\/en\/ITCG\/threads\/\"><span style=\"color: #0000ff\">Official Scripting Guys Forum<\/span><\/a>. See you tomorrow. Until then, peace.<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><span style=\"font-size: 10pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 8pt\"><b><span style=\"font-size: 10pt\">Ed Wilson, Microsoft Scripting Guy<\/span><\/b><span style=\"font-size: 10pt\">&nbsp;<\/span><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Summary: Learn how to use a Windows PowerShell module to work with WMI permanent events. &nbsp; Hey, Scripting Guy! Your posts this week on permanent event consumers have been really cool. I am wondering, if they are so useful, why there is not a Windows PowerShell cmdlet to allow one to interact with them? [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[42,56,3,4,211,45,6],"class_list":["post-16281","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-events-and-monitoring","tag-guest-blogger","tag-scripting-guy","tag-scripting-techniques","tag-trevor-sullivan","tag-windows-powershell","tag-wmi"],"acf":[],"blog_post_summary":"<p>&nbsp; Summary: Learn how to use a Windows PowerShell module to work with WMI permanent events. &nbsp; Hey, Scripting Guy! Your posts this week on permanent event consumers have been really cool. I am wondering, if they are so useful, why there is not a Windows PowerShell cmdlet to allow one to interact with them? [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/16281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=16281"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/16281\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=16281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=16281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=16281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}