<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.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>MshObject and Methods that take object</title><link>http://blogs.msdn.com/monad/archive/2005/09/02/460075.aspx</link><description>Every once in a while people ( including me) run into trouble calling methods that take object. Why? Well, as I told you earlier objects in MSH are wrapped by an invisible MshObject. As it turns out that this invisible object is not always so invisible.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: MshObject and Methods that take object</title><link>http://blogs.msdn.com/monad/archive/2005/09/02/460075.aspx#460769</link><pubDate>Sun, 04 Sep 2005 13:08:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:460769</guid><dc:creator>Thomas Lee</dc:creator><description>Here's what I get when I try this:&lt;br&gt;&lt;br&gt;[C:\]: $key= get-item .&lt;br&gt;[C:\]: $hash=@()&lt;br&gt;[C:\]: $hash[$key]='foo'&lt;br&gt; : Array assignment to [C:\] failed: Specified cast is not valid.&lt;br&gt;At line:1 char:7&lt;br&gt;+ $hash[$ &amp;lt;&amp;lt;&amp;lt;&amp;lt; key]='foo'&lt;br&gt;&lt;br&gt;Am I missing something?</description></item><item><title>re: MshObject and Methods that take object</title><link>http://blogs.msdn.com/monad/archive/2005/09/02/460075.aspx#460859</link><pubDate>Sun, 04 Sep 2005 23:50:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:460859</guid><dc:creator>Marcel</dc:creator><description>The line where you are creating the hashtable is wrong.  &lt;br&gt;$hash = @(); # will create an empty array.&lt;br&gt;$hash = @{}; # will create an empty hashtable.</description></item><item><title>re: MshObject and Methods that take object (WMI method problem)</title><link>http://blogs.msdn.com/monad/archive/2005/09/02/460075.aspx#473924</link><pubDate>Mon, 26 Sep 2005 14:07:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:473924</guid><dc:creator>MOW</dc:creator><description>Calling Methods on WMI Object&lt;br&gt;&lt;br&gt;this script keeps saying there is no Uninstall Method in win32_Product (there is!)&lt;br&gt;&lt;br&gt;-------------&lt;br&gt;&lt;br&gt;$computer=&amp;quot;LocalHost&amp;quot;&lt;br&gt;&lt;br&gt;$Progs=$(get-wmiobject win32_Product -computer $computer)&lt;br&gt;&lt;br&gt; foreach ($p in $Progs) {&lt;br&gt;    &lt;br&gt;     If ($P.Caption -eq &amp;quot;MowTool Setup&amp;quot;)&lt;br&gt;       {&lt;br&gt;        &amp;quot;Prog $($p.Caption) Found&amp;quot;&lt;br&gt;&lt;br&gt;        $R = $p.baseobject.Uninstall()&lt;br&gt; &amp;quot;  Return $($R) &amp;quot;&lt;br&gt;       }&lt;br&gt;     Else&lt;br&gt;       {&lt;br&gt;        &amp;quot;Progs   $($p.Caption) Skipped&amp;quot; &lt;br&gt;       }&lt;br&gt;  } #end foreach&lt;br&gt;--------&lt;br&gt;&lt;br&gt;This Vbscript Version Does Work &lt;br&gt;&lt;br&gt;--------&lt;br&gt;Computer = &amp;quot;.&amp;quot;&lt;br&gt;&lt;br&gt;Set objWMIService = GetObject(&amp;quot;winmgmts:\\&amp;quot; &amp;amp; Computer &amp;amp; &amp;quot;\root\cimv2&amp;quot;) &lt;br&gt;Set colItem = objWMIService.ExecQuery(&amp;quot;Select * from Win32_Product&amp;quot;) &lt;br&gt;&lt;br&gt;&lt;br&gt;For each objItem in colItem &lt;br&gt;  if objItem.Caption = &amp;quot;MowTool Setup&amp;quot; then&lt;br&gt; wscript.echo &amp;quot;Found &amp;quot; &amp;amp; objItem.Caption&lt;br&gt; objItem.Uninstall()&lt;br&gt;else&lt;br&gt;wscript.echo &amp;quot;skipped &amp;quot; &amp;amp; objItem.Caption&lt;br&gt;  end if&lt;br&gt;Next &lt;br&gt;&lt;br&gt;---------&lt;br&gt;&lt;br&gt;Where is the method gone in the MSH version ?&lt;br&gt;&lt;br&gt;someone got a clue ?&lt;br&gt;&lt;br&gt;greetings /\/\o\/\/&lt;br&gt;</description></item><item><title>re: MshObject and Methods that take object</title><link>http://blogs.msdn.com/monad/archive/2005/09/02/460075.aspx#474332</link><pubDate>Tue, 27 Sep 2005 13:58:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:474332</guid><dc:creator>/\/\o\/\/</dc:creator><description>answer from m.p.s.scripting newsgroup :&lt;br&gt;&lt;br&gt;MSH does not currently support invoking WMI class methods directly.&lt;br&gt;&lt;br&gt;You can still call them by changing the line:&lt;br&gt;  $R = $p.baseobject.Uninstall()&lt;br&gt;into:&lt;br&gt;  $R = $p.InvokeMethod(&amp;quot;Uninstall&amp;quot;, $null)&lt;br&gt;&lt;br&gt;gr /\/\o\/\/</description></item><item><title>re: MshObject and Methods that take object</title><link>http://blogs.msdn.com/monad/archive/2005/09/02/460075.aspx#493754</link><pubDate>Thu, 17 Nov 2005 08:06:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:493754</guid><dc:creator>Keith Hill</dc:creator><description>&amp;gt;&amp;gt; $hash.ContainsKey($key)&lt;br&gt;&lt;br&gt;That's unfortunate since this type of problem can really trip up folks and can be hard to debug.  Too bad there isn't a better solution.</description></item></channel></rss>