<?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>Expert Commentary: 2012 Scripting Games Advanced Event 9</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/04/26/expert-commentary-2012-scripting-games-advanced-event-9.aspx</link><description>Microsoft MVP, Arnaud Petitjean, provides expert commentary for 2012 Scripting Games Advanced Event 9.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Expert Commentary: 2012 Scripting Games Advanced Event 9</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/04/26/expert-commentary-2012-scripting-games-advanced-event-9.aspx#3494870</link><pubDate>Fri, 27 Apr 2012 05:50:28 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3494870</guid><dc:creator>Jaap Brasser</dc:creator><description>&lt;p&gt;The problem with counting the capacity values in win32_physicalmemory is that you might not only get the physicalmemory you are looking for as detailed in MSDN, &lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa394347(v=vs.85).aspx"&gt;msdn.microsoft.com/.../aa394347(v=vs.85).aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is an example on one of my computers, as you can see just counting capacity would not give you an accurate representation of the physical memory eg:&lt;/p&gt;
&lt;p&gt;tag &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; formfactor typedetail &amp;nbsp; capacity&lt;/p&gt;
&lt;p&gt;--- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ---------- ---------- &amp;nbsp; --------&lt;/p&gt;
&lt;p&gt;Physical Memory 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;128 1073741824&lt;/p&gt;
&lt;p&gt;Physical Memory 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;128 1073741824&lt;/p&gt;
&lt;p&gt;Physical Memory 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;128 1073741824&lt;/p&gt;
&lt;p&gt;Physical Memory 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; 4096 &amp;nbsp; &amp;nbsp;4194304&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3494870" width="1" height="1"&gt;</description></item><item><title>re: Expert Commentary: 2012 Scripting Games Advanced Event 9</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/04/26/expert-commentary-2012-scripting-games-advanced-event-9.aspx#3494753</link><pubDate>Thu, 26 Apr 2012 15:50:36 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3494753</guid><dc:creator>Cameron Wilson</dc:creator><description>&lt;p&gt;Hmm... I didn&amp;#39;t think the adapter with &amp;quot;index 0&amp;quot; would be counted as the &amp;quot;primary&amp;quot; network adapter -- especially considering my active network adapter on my machine is actually #2. &amp;nbsp;How I achieved the primary network adapter was to look at the binding order of the network adapters and choose the adapter with index 0 in the binding order. &amp;nbsp;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3494753" width="1" height="1"&gt;</description></item><item><title>re: Expert Commentary: 2012 Scripting Games Advanced Event 9</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/04/26/expert-commentary-2012-scripting-games-advanced-event-9.aspx#3494668</link><pubDate>Thu, 26 Apr 2012 09:41:26 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3494668</guid><dc:creator>aml</dc:creator><description>&lt;p&gt;Most of the examples I&amp;#39;ve seen use TotalPhysical memory from win32_computersystem to determine how much RAM is in the machine. &amp;nbsp;But this is always slightly off. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;The value in TotalPhysicalMemory is the physical memory minus the memory reserved for hardware; it&amp;#39;s the memory the operating system has to use. &amp;nbsp;(If you fire up resource monitor from within task manager and go to the memory tab, you&amp;#39;ll see how much memory is assigned to hardware.)&lt;/p&gt;
&lt;p&gt;A more accurate measure of memory is in win32_physicalmemory. &amp;nbsp;You can get the machine&amp;#39;s physical memory with something like:&lt;/p&gt;
&lt;p&gt;$physicalMemory = 0&lt;/p&gt;
&lt;p&gt;$wmiPhysicalMemory = Get-WMIObject -class win32_physicalmemory&lt;/p&gt;
&lt;p&gt;$wmiPhysicalMemory | foreach-object{$physicalMemory += [int64]($_.Capacity)}&lt;/p&gt;
&lt;p&gt;Most of the time the values are pretty similar, but it&amp;#39;s nicer to have a value like 4GB for memory, instead of something 3.87GB. &amp;nbsp;I used TotalPhysicalMemory as my fallback value, and used win32_physicalmemory as the preferred option.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3494668" width="1" height="1"&gt;</description></item><item><title>re: Expert Commentary: 2012 Scripting Games Advanced Event 9</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/04/26/expert-commentary-2012-scripting-games-advanced-event-9.aspx#3494665</link><pubDate>Thu, 26 Apr 2012 09:31:35 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3494665</guid><dc:creator>aml</dc:creator><description>&lt;p&gt;Another approach is to look at the routing table, whichever NIC has the default route (0.0.0.0) has a good claim to being the primary NIC. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;	$defaultNICID = (get-wmiobject -class win32_ip4routetable | &lt;/p&gt;
&lt;p&gt;				 where-object{$_.Destination -eq &amp;quot;0.0.0.0&amp;quot;}).interfaceindex&lt;/p&gt;
&lt;p&gt;The interface index you get back matches the interface index used in win32_networkadapter and allows you to work out which has the default route.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3494665" width="1" height="1"&gt;</description></item></channel></rss>