<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://powershell.com/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results for 'app:weblogs' matching tags 'wmi' and 'security'</title><link>http://powershell.com/cs/search/SearchResults.aspx?q=app:weblogs&amp;tag=wmi,security&amp;orTags=0&amp;o=DateDescending</link><description>Search results for 'app:weblogs' matching tags 'wmi' and 'security'</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 (Build: 30929.2835)</generator><item><title>Find Files with WMI and PowerShell</title><link>http://powershell.com/cs/blogs/lonelyadministrator/archive/2013/01/29/find-files-with-wmi-and-powershell.aspx</link><pubDate>Tue, 29 Jan 2013 06:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:21312</guid><dc:creator>Anonymous</dc:creator><description>Finding files is one of those necessary evils for IT Pros. Sometimes we&amp;#8217;re searching for a needle in a haystack. And it gets even more complicated when the haystacks are on 10 or 100 or 1000 remote computers. You might think using Get-ChildItem is your only option. Certainly it works, but if you are searching [...]</description></item><item><title>Scripting with PSCredential</title><link>http://powershell.com/cs/blogs/lonelyadministrator/archive/2012/04/10/scripting-with-pscredential.aspx</link><pubDate>Tue, 10 Apr 2012 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:15889</guid><dc:creator>Anonymous</dc:creator><description>
I see this question often: how can I pass a parameter value for a PSCredential that might be a credential object or it might be a user name? In the past I&amp;#8217;ve used code like this: begin &amp;#123; &amp;#160; &amp;#160; &amp;#8230; &lt;a href="http://jdhitsolutions.com/blog/2012/04/scripting-with-pscredential/"&gt;Continue reading &lt;span class="meta-nav"&gt;&amp;#8594;&lt;/span&gt;&lt;/a&gt;</description></item><item><title>Use PowerShell to Convert SDDL to Binary Format</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2011/08/09/use-powershell-to-convert-sddl-to-binary-format.aspx</link><pubDate>Tue, 09 Aug 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:11772</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;: Learn how to use Windows PowerShell to convert security descriptors to different formats.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img title="Hey, Scripting Guy! Question" border="0" alt="Hey, Scripting Guy! Question" align="left" src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/q-sm.jpg" width="34" height="34" /&gt;Hey, Scripting Guy! I was reading through a listing of WMI methods recently, and I ran across a WMI class that looks interesting&amp;mdash;&lt;b&gt;Win32_SecurityDescriptorHelper&lt;/b&gt;. I think it will help me, because it seems like every security utility wants a different type of security token. But I am not sure how to use this thing; all I get are errors. Does this even work? Any help on your end?&lt;/p&gt;
&lt;p&gt;&amp;mdash;SH&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img title="Hey, Scripting Guy! Answer" border="0" alt="Hey, Scripting Guy! Answer" align="left" src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/a-sm.jpg" width="34" height="34" /&gt;Hello SH,&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy Ed Wilson here. Tonight is the big night. They say everything is big in Texas, so let&amp;rsquo;s fill up the conference center for &lt;a href="http://powershellgroup.org/corpus.tx"&gt;the inaugural meeting of the Corpus Christi PowerShell User group (south Texas)&lt;/a&gt;. The Scripting Wife and I will be on hand for the event, and I have a really cool presentation planned.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;&amp;nbsp; &amp;nbsp;Four articles talk about producing a usable listing of WMI methods and properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2011/03/10/use-powershell-to-find-wmi-classes-that-contain-methods.aspx"&gt;Use PowerShell to Find WMI Classes That Contain Methods&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2011/03/11/use-powershell-to-find-writable-wmi-properties.aspx"&gt;Use PowerShell to Find Writable WMI Properties&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2011/03/12/explore-wmi-methods-and-properties-via-powershell-script.aspx"&gt;Explore WMI Methods and Properties Via PowerShell Script&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2011/03/13/get-all-methods-and-writable-properties-from-all-wmi-classes.aspx"&gt;Get All Methods and Writable Properties from All WMI Classes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When working with WMI and Windows PowerShell, it is common to think about using the &lt;b&gt;Get-WmiObject&lt;/b&gt; cmdlet. Unfortunately, when using the &lt;b&gt;Get-WmiObject&lt;/b&gt; cmdlet with the &lt;b&gt;Win32_SecurityDescriptorHelper&lt;/b&gt; class, nothing happens. When I attempt to pipe the results to &lt;b&gt;Get-Member&lt;/b&gt;, an error is produced. The two commands are shown here (&lt;b&gt;gwmi&lt;/b&gt; is an alias for &lt;b&gt;Get-WmiObject&lt;/b&gt;, and &lt;b&gt;gm&lt;/b&gt; is an alias for &lt;b&gt;Get-Member&lt;/b&gt;):&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;gwmi win32_SecurityDescriptorHelper #no output&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;gwmi win32_SecurityDescriptorHelper | gm #generates an error&lt;/p&gt;
&lt;p&gt;The commands and associated output are shown here.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/4705.HSG_2D00_8_2D00_9_2D00_11_2D00_01.png"&gt;&lt;img style="border:0px;" title="Image of commands and associated output" alt="Image of commands and associated output" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/4705.HSG_2D00_8_2D00_9_2D00_11_2D00_01.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now, I remember the discussion from &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2011/08/08/learn-four-ways-to-kill-a-process-using-powershell-and-wmi.aspx"&gt;yesterday&amp;rsquo;s blog post&lt;/a&gt; about calling WMI methods that there are both instance methods and static methods.&lt;/p&gt;
&lt;p&gt;Therefore, I will use the &lt;b&gt;Get-Member&lt;/b&gt; cmdlet and choose static members. I wonder what will happen then? I therefore use &lt;b&gt;Get-WmiObject&lt;/b&gt; and this time request static members from &lt;b&gt;Get-Member&lt;/b&gt;. The command is shown here (&lt;b&gt;gwmi&lt;/b&gt; is an alias for &lt;b&gt;Get-WmiObject&lt;/b&gt;, and &lt;b&gt;gm&lt;/b&gt; is an alias for &lt;b&gt;Get-Member&lt;/b&gt;):&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;gwmi win32_SecurityDescriptorHelper | gm &amp;ndash;Static&lt;/p&gt;
&lt;p&gt;The command and associated output appear here.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/6254.HSG_2D00_8_2D00_9_2D00_11_2D00_02.png"&gt;&lt;img style="border:0px;" title="Image of commands and associated output" alt="Image of command and associated output" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/6254.HSG_2D00_8_2D00_9_2D00_11_2D00_02.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Maybe this is not so strange. For example, nothing came back when I used &lt;b&gt;Get-WmiObject Win32_SecurityDescriptorHelper&lt;/b&gt; So maybe &lt;b&gt;Get-Member&lt;/b&gt; is not lying to me, and maybe there really is nothing with which to work. I look up the &lt;a href="http://msdn.microsoft.com/en-us/library/aa394403(VS.85).aspx"&gt;Win32_SecurityDescriptorHelper class on MSDN&lt;/a&gt;, but unfortunately, the page has very little information that is useful and no examples of using the class.&lt;/p&gt;
&lt;p&gt;Next, I decide to look up the class in the Windows Management Instrumentation Tester (WbemTest). From WbemTest, I see that the &lt;b&gt;Win32_SecurityDescriptorHelper&lt;/b&gt; is a dynamic class, and I see that there are many methods available from the class. This is shown in the following figure.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/4174.HSG_2D00_8_2D00_9_2D00_11_2D00_03.png"&gt;&lt;img style="border:0px;" title="Image of Win32_SecurityDescriptorHelper being dynamic class with many methods" alt="Image of Win32_SecurityDescriptorHelper being dynamic class with many methods " src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/4174.HSG_2D00_8_2D00_9_2D00_11_2D00_03.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;When I click the Instances&lt;i&gt; &lt;/i&gt;button (sixth button from top on right side), I see that there are no instances available. I then click the Show MOF&lt;i&gt; &lt;/i&gt;button (third button from top on right side), and I see that all methods are implemented. A method will only work if it is marked as implemented. For example, the &lt;b&gt;Win32_Processor&lt;/b&gt; WMI class has two methods listed: &lt;b&gt;Reset&lt;/b&gt; and &lt;b&gt;SetPowerState&lt;/b&gt;. Unfortunately, neither method is implemented and therefore they do not work (in the case of &lt;b&gt;Win32_Processor&lt;/b&gt;, the methods are defined on the abstract class &lt;b&gt;CIM_LogicalDevice&lt;/b&gt; and are inherited). The MOF description for the &lt;b&gt;Win32_SecurityDescriptorHelper&lt;/b&gt; WMI class is shown in the following figure.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/8004.HSG_2D00_8_2D00_9_2D00_11_2D00_04.png"&gt;&lt;img style="border:0px;" title="Image of MOF description of Win32_SecurityDescriptorHelper" alt="Image of MOF description of Win32_SecurityDescriptorHelper" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/8004.HSG_2D00_8_2D00_9_2D00_11_2D00_04.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I also notice that each method is static. From yesterday&amp;rsquo;s article, I remember that static methods do use an instance of the WMI class. This is why the &lt;b&gt;Get-WmiObject&lt;/b&gt; command does not work with &lt;b&gt;Win32_SecurityDescriptorHelper&lt;/b&gt; because &lt;b&gt;Get-WmiObject&lt;/b&gt; returns instances of the class. With this WMI class, there are no instances.&lt;/p&gt;
&lt;p&gt;Perhaps the easiest way to work with the static WMI method is to use the &lt;b&gt;[wmiclass]&lt;/b&gt; type accelerator. The &lt;b&gt;SDDLToBinarySD&lt;/b&gt; method will translate a Security Descriptor Definition Language (SDDL) string into a binary byte array security descriptor (binary SD) format. The best way to talk about this technique is to walk through an example of converting an SDDL to a binary SD. First, I need to obtain an SDDL; I can do that by using the &lt;b&gt;Get-Acl&lt;/b&gt; cmdlet. The first thing I do is give the &lt;b&gt;Get-Acl&lt;/b&gt; the path to a file on my computer. I store the resulting object in the &lt;b&gt;$acl&lt;/b&gt; variable. Next, I examine the SDDL associated with the file, by querying the &lt;b&gt;SDDL&lt;/b&gt; property. These two lines of code are shown here:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$acl = Get-Acl C:\fso\BackupLog.txt&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$acl.Sddl&lt;/p&gt;
&lt;p&gt;The two commands and their associated output are shown here.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7652.HSG_2D00_8_2D00_9_2D00_11_2D00_05.png"&gt;&lt;img style="border:0px;" title="Image of two commands and associated output" alt="Image of two commands and associated output" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7652.HSG_2D00_8_2D00_9_2D00_11_2D00_05.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To convert the SDDL to binary SD format, I use the &lt;b&gt;[wmiclass]&lt;/b&gt; type accelerator and call the method directly while supplying a SDDL to the &lt;b&gt;SDDLToBinarySD&lt;/b&gt; method. The syntax for the command is shown here:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;([wmiclass]&amp;quot;Win32_SecurityDescriptorHelper&amp;quot;).SDDLToBinarySD($acl.Sddl)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;One thing that is a bit confusing is that in Windows PowerShell, generally double colons are required to call a static method. For example, to obtain the sine of a 45-degree angle, I use the &lt;b&gt;sin&lt;/b&gt; static method from the math class:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;[math]::sin(45)&lt;/p&gt;
&lt;p&gt;But here in WMI, there appears to be no difference between calling a static method and calling an instance method. The command to convert the SDDL to binary SD and the default output are shown in the following figure.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/3426.HSG_2D00_8_2D00_9_2D00_11_2D00_06.png"&gt;&lt;img style="border:0px;" title="Image of command to convert SDDL to binary SD, and default ouput" alt="Image of command to convert SDDL to binary SD, and default ouput" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/3426.HSG_2D00_8_2D00_9_2D00_11_2D00_06.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;All the methods return both the &lt;b&gt;returnvalue&lt;/b&gt; property that provides the status of the command and the specific output for the converted security descriptor. To retrieve only the BinarySD output, I can add that to the end of the method call. The syntax of this command is shown here:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;([wmiclass]&amp;quot;Win32_SecurityDescriptorHelper&amp;quot;).SDDLToBinarySD($acl.Sddl).BinarySD&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;One of the cool things that I can do with the static methods from the &lt;b&gt;Win32_SecurityDescriptorHelper&lt;/b&gt; class is to convert a SDDL security descriptor into an instance of the &lt;b&gt;Win32_SecurityDescriptor&lt;/b&gt; WMI class. The &lt;b&gt;Win32_SecurityDescriptor&lt;/b&gt; WMI class is often used to provide security for various resources. For example, if I create a new share and I want to assign security to the new share, I will need to provide an instance of &lt;b&gt;Win32_SecurityDescriptor&lt;/b&gt;. Using the &lt;b&gt;SDDLToWin32SD&lt;/b&gt; method, I can use an SDDL to get the &lt;b&gt;Win32_SecurityDescriptor&lt;/b&gt; I need. To illustrate using the &lt;b&gt;SDDLToWin32SD&lt;/b&gt; method, I will use the &lt;b&gt;Invoke-WmiMethod&lt;/b&gt; to perform the conversion. The following one-line command illustrates using the &lt;b&gt;Invoke-WMIMethod&lt;/b&gt; cmdlet to call the &lt;b&gt;SDDLToWin32SD&lt;/b&gt; method:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Invoke-WmiMethod -Class Win32_SecurityDescriptorHelper -Name SDDLToWin32SD -ArgumentList $acl.Sddl&lt;/p&gt;
&lt;p&gt;The following figure illustrates calling the method and shows the returned data. The data is contained in the &lt;b&gt;Descriptor&lt;/b&gt; property.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/3240.HSG_2D00_8_2D00_9_2D00_11_2D00_07.png"&gt;&lt;img style="border:0px;" title="Image of calling the method and the returned data" alt="Image of calling the method and the returned data" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/3240.HSG_2D00_8_2D00_9_2D00_11_2D00_07.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The other WMI methods from this class behave in a similar mechanism, and therefore will not be explored.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;SH, that is all there is to using static WMI methods. WMI Method Week will continue tomorrow when I will talk about using Windows PowerShell and WMI to terminate multiple processes. It is a really cool article. I think you will enjoy it. I literally create a hundred processes, and then terminate them.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3445152" width="1" height="1" alt="" /&gt;</description></item><item><title>Hey, Scripting Guy! Quick-Hits Friday: The Scripting Guys Respond to a Bunch of Questions (6/18/10)</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2010/06/18/hey-scripting-guy-quick-hits-friday-the-scripting-guys-respond-to-a-bunch-of-questions-6-18-10.aspx</link><pubDate>Fri, 18 Jun 2010 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:6869</guid><dc:creator>Anonymous</dc:creator><description>In this post : In Windows PowerShell, How Can I Pipe the Contents of a Property to a Command? Using WMI for Security Event Log Tracing &amp;#160; In Windows PowerShell, How Can I Pipe the Contents of a Property to a Command? &amp;#160; Hey, Scripting Guy! I’m...(&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2010/06/18/hey-scripting-guy-quick-hits-friday-the-scripting-guys-respond-to-a-bunch-of-questions-6-18-10.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3338744" width="1" height="1" alt="" /&gt;</description></item></channel></rss>