W2KSG: WMI Total Physical Memory

I have decided to jump to the WMI section.  The VBScript dictionary object is equivalent (ish) to the PowerShell hash table which has been covered in many places.  Chapter 5 is on ADSI and having just finished writing a big chapter on that for my book I wanted to look at something else.

Chapter 6 in the scripting guide covers WMI.  PowerShell has great WMI support so if we look at

Script Center Home > Microsoft Windows 2000 Scripting Guide > Scripting Concepts and Technologies for System Administration > WMI Scripting Primer  WMI Overview

Listing 6.1 shows us how to get the Total Physical Memory on a machine (10 lines of VBScript)

The listing uses the Win32_LogicalMemoryConfiguration class so we turn the script into

Get-WmiObject -Class Win32_LogicalMemoryConfiguration | Select TotalPhysicalMemory

However, XP and later don’t support this so we use

Get-WmiObject -Class Win32_OperatingSystem | Select TotalVisibleMemorySize

This is one area where research pays off as WMI is evolving and changing with each version of Windows

 


Share this post :

 

Technorati Tags: ,,

About these ads
This entry was posted in PowerShell and WMI. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s