PowerShell for Windows Admins

Dec 16 2009   3:27PM GMT

System Discovery Part 3



Posted by: Richard Siddaway
Tags:
Operating System

The class description for Win32_OperatingSystem can be found here.  Access to the WMI reference information starts at http://msdn.microsoft.com/en-us/library/aa394572(VS.85).aspx

If we look at the Win32_OperatingSystem class description we will see that there are a number of properties where we can get numeric values returned. These don’t tell us a lot unless we happened to have memorised the table of values. There may be a test later!

Lets see what we have at the moment

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
CSName                                    : RSLAPTOP01
Caption                                   : Microsoft Windows 7 Ultimate 
ServicePackMajorVersion                   : 0
ServicePackMinorVersion                   : 0
BuildNumber                               : 7600
Version                                   : 6.1.7600
OSArchitecture                            : 32-bit
SystemDevice                              : \Device\HarddiskVolume2
SystemDrive                               : C:
WindowsDirectory                          : C:\Windows
SystemDirectory                           : C:\Windows\system32
OSLanguage                                : 1033
OSProductSuite                            : 256
OSType                                    : 18
CodeSet                                   : 1252
CountryCode                               : 44
EncryptionLevel                           : 256
ForegroundApplicationBoost                : 2
DataExecutionPrevention_32BitApplications : True
DataExecutionPrevention_Available         : True
DataExecutionPrevention_Drivers           : True
DataExecutionPrevention_SupportPolicy     : 2
Installation Date                         : 07/08/2009 11:38:52
Last Bootup time                          : 16/12/2009 14:02:58
Local Date Time                           : 16/12/2009 20:53:30
Locale                                    : 0809
FreePhysicalMemory                        : 1498944
SizeStoredInPagingFiles                   : 2881972
FreeSpaceInPagingFiles                    : 2683264
TotalVisibleMemorySize                    : 2881972
TotalVirtualMemorySize                    : 5763944
FreeVirtualMemory                         : 3921460

Now some of these look like candidates for translation.  I am not going to show all possible answers as some of these tables get quite large as you will see when examining the documentation.  I’ll give a couple of examples that work for the environments I work in.

We can modify our script as follows

 

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
$os = DATA {
ConvertFrom-StringData -StringData @’
14 = MSDOS
15 = WIN3X
16 = WIN95
17 = WIN98
18 = WINNT
19 = WINCE
‘@

}

Get-WmiObject -Class Win32_OperatingSystem | Format-List CSName, Caption, `
ServicePackMajorVersion, ServicePackMinorVersion, BuildNumber, Version, `
OSArchitecture, SystemDevice, SystemDrive, WindowsDirectory, SystemDirectory, `
OSLanguage, OSProductSuite, `
@{Name="OS Type"; Expression={$os["$($_.OSType)"]}}, `
CodeSet, CountryCode, EncryptionLevel, `
ForegroundApplicationBoost, DataExecutionPrevention_32BitApplications, `
DataExecutionPrevention_Available, DataExecutionPrevention_Drivers, `
DataExecutionPrevention_SupportPolicy, `
@{Name=”Installation Date”; Expression={$_.ConvertToDateTime($_.InstallDate)}}, `
@{Name=”Last Bootup time”; Expression={$_.ConvertToDateTime($_.LastBootUpTime)}}, `
@{Name=”Local Date Time”; Expression={$_.ConvertToDateTime($_.LocalDateTime)}}, `
Locale, FreePhysicalMemory, SizeStoredInPagingFiles, FreeSpaceInPagingFiles, `
TotalVisibleMemorySize, TotalVirtualMemorySize, FreeVirtualMemory

We create a hash table of the numeric values and their translated meaning.  I’ve truncated the possible OS types that can be returned because I am only expecting Windows Operating Systems.

We can create another calculated field to get the value returned from the hash table.

I’ll work out the others and post a single script with them all in.  We also need to do something with the memory fields as they are current quoted in KB which isn’t the easiest of levels to work with.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: