The VBScript Network and Systems Administrator's Cafe:

March, 2009

Mar 31 2009   1:22PM GMT

Writing a BGINFO like Script: Displaying Memory information via WMI using the Win32_PhysicalMemory class



Posted by: Jerry Lees
bginfo, VBScript, VBScript Functions, Systems Administration, systems management, Systems administrator tools, systems reporting

I recently had to provide the information displayed with BGINFO on a number of systems. Unfortunately, BGInfo only generates a bitmap, so far as I know, so I decided to write a script to generate the information and use this displayed information to send back to the person who requested it.

The function below is a part of the script I mentioned. It retrieves and returns text that represents the total amount of physical memory in a system.

You can view all the scripts in this BGINFO series here.

Here is the code:

Function GetPhysicalMemory(strComputer)
Dim colItems, objItem, address
Dim StrQuery
Dim objWMIService, RAM
GetPhysicalMemory = VbCrLf
RAM = 0

StrQuery = “SELECT * FROM Win32_PhysicalMemory”
Set objWMIService = GetObject(”winmgmts:\\” & strComputer & “\root\CIMV2″)
Set colItems = objWMIService.ExecQuery(strQuery,,48)

For Each objItem in colItems
RAM = RAM + objItem.capacity
Next
GetPhysicalMemory = GetPhysicalMemory & vbTab & (((RAM/1024)/1024)/1024) & ” Gb” & VbCrLf
End Function

Mar 30 2009   4:13PM GMT

Writing a BGINFO like Script: Displaying Processor information with WMI via the Win32_Processor class



Posted by: Jerry Lees
bginfo, VBScript, VBScript Functions, Systems Administration, systems management, Systems administrator tools, systems reporting

I recently had to provide the information displayed with BGINFO on a number of systems. Unfortunately, BGInfo only generates a bitmap, so far as I know, so I decided to write a script to generate the information and use this displayed information to send back to the person who requested it.

The function below is a part of the script I mentioned. It retrieves and returns text that represents the Processor information in the system and teh number of processors in the system. (Note: At this time I don’t have a dual core system to test it with, I believe that it will diplay the number of cores in the system. So, 4 dual core processors will be displayed as 8 processors/cores.)

You can view all the scripts in this BGINFO series here.

Here is the code:

Function GetCPUs(strComputer)
Dim colItems, objItem, address
Dim StrQuery
Dim objWMIService
Dim CoresCores = 0

 

 

StrQuery = “SELECT * FROM Win32_Processor”
Set objWMIService = GetObject(”winmgmts:\\” & strComputer & “\root\CIMV2″)
Set colItems = objWMIService.ExecQuery(strQuery,,48)

For Each objItem in colItems
If Replace objItem.name,”GHz”,””) = objItem.name then
GetCPUs =(round(objItem.CurrentClockSpeed/1024,1)) & “GHz” & ” ” & objItem.name & VbCrLf
Else
GetCPUs = objItem.name & VbCrLf
end if
Cores = Cores + 1
Next
GetCPUs =  vbTab & Cores & ” Processors/Cores that are: ” & GetCPUs
End Function


Mar 25 2009   2:49PM GMT

Writing a BGINFO like Script: Displaying MAC Address information with WMI via the Win32_NetworkAdapter class



Posted by: Jerry Lees
bginfo, VBScript, VBScript Functions, Systems Administration, systems management, Systems administrator tools, systems reporting

I recently had to provide the information displayed with BGINFO on a number of systems. Unfortunately, BGInfo only generates a bitmap, so far as I know, so I decided to write a script to generate the information and use this displayed information to send back to the person who requested it.

The function below is a part of the script I mentioned. It retrieves and returns text that represents the total space and the total free space on all the physical hard drives in a system.

You can view all the scripts in this BGINFO series here.

Here is the code:

Function GetMACAddress(strComputer)
Dim colItems, objItem, address
Dim StrQuery
Dim objWMIService

StrQuery = “SELECT * FROM Win32_NetworkAdapter”
Set objWMIService = GetObject(”winmgmts:\\” & strComputer & “\root\CIMV2″)
Set colItems = objWMIService.ExecQuery(strQuery,,48)

For Each objItem in colItems
if objitem.MACAddress <> vbnull Then
GetMACAddress = GetMACAddress & vbTab & objItem.name & “: ” & objItem.MACAddress & VbCrLf
End If
Next
End Function


Mar 24 2009   4:13PM GMT

Win an Xbox 360 console just for asking questions and answering questions about stuff related to IT!



Posted by: Jerry Lees
Xbox360, Xbox, Xbox Live, VBScript

Ok folks, I know some of you probably already have an Xbox 360 but with the RROD ever of the horizon a person could always use a replacement— right?!?!?!

Well, TechTarget is running a contest to give you the opportunity to do just that– Win a Xbox 360 console!

I personally have won prize in a contest here before and I can vouch for the fact that you do in fact get your prizes… so If you know about Information Technology, or If you have questions about it, head on over there and sign up to win an Xbox 360 by answering and asking some questions!!

If you read my blog you’ll remember a while back I wrote a post that worked with a third party data feed for Xbox Live! gamertag games played information for the last Xbox360 promotion. Pretty cool stuff!

If you already own an Xbox360, or if you win the contest, send me a friend request, we’ll play a few games together… and definitely check out 360voice for their content. My GamerTag is CrashSerious.

After you do, run over to my website to create Xbox360 Gamer signatures and get yourself a free Gamer Signature like this one:


Like the signature powered by 360voice?get your FREE signature here.

Game on!!!


Mar 20 2009   4:32PM GMT

Writing a BGINFO like Script: Displaying DNS Server settings with WMI via the Win32_NetworkAdapterConfiguration class



Posted by: Jerry Lees
bginfo, VBScript, VBScript Functions, Systems Administration, systems management, Systems administrator tools, systems reporting

I recently had to provide the information displayed with BGINFO on a number of systems. Unfortunately, BGInfo only generates a bitmap, so far as I know, so I decided to write a script to generate the information and use this displayed information to send back to the person who requested it.

The function below is a part of the script I mentioned. It retrieves and returns text that represents the DNS Server settings for the network adapters in the system.

You can view all the scripts in this BGINFO series here.

Here is the code:

Function GetDNSAddress(strComputer)
on error resume next
Dim colItems, objItem, address
Dim StrQuery
Dim objWMIService
Dim IP

StrQuery = “SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True”
Set objWMIService = GetObject(”winmgmts:\\” & strComputer & “\root\CIMV2″)
Set colItems = objWMIService.ExecQuery(strQuery,,48)

For Each objItem in colItems
For Each address In objItem.DNSServerSearchOrder
IP = replace(address,”:”,””)
‘IP = Replace(IP,vbnull,”No IP Assigned”)
GetDNSAddress = GetDNSAddress & vbTab & mid(objItem.caption,InStr(objItem.caption,”]”)+2) & “: ” & IP & vbcrLF
Next
Next
On Error GoTo 0
End Function


Mar 17 2009   4:36PM GMT

Writing a BGINFO like Script: Displaying Network Adapter Speed with WMI via the Win32_NetworkAdapter class



Posted by: Jerry Lees
bginfo, VBScript, VBScript Functions, Systems Administration, systems management, Systems administrator tools, systems reporting

I recently had to provide the information displayed with BGINFO on a number of systems. Unfortunately, BGInfo only generates a bitmap, so far as I know, so I decided to write a script to generate the information and use this displayed information to send back to the person who requested it.

The function below is a part of the script I mentioned. It retrieves and returns text that represents the speed of teh network adapters in a system.

You can view all the scripts in this BGINFO series here.

Here is the code:

Function GetNetworkSpeed(strComputer)
Dim colItems, objItem, address
Dim StrQuery
Dim objWMIService

StrQuery = “SELECT * FROM Win32_NetworkAdapter”
Set objWMIService = GetObject(”winmgmts:\\” & strComputer & “\root\CIMV2″)
Set colItems = objWMIService.ExecQuery(strQuery,,48)

For Each objItem in colItems
GetNetworkSpeed = GetNetworkSpeed & vbTab & objItem.ProductName & vbCr
Next
End Function


Mar 13 2009   11:05AM GMT

Writing a BGINFO like Script: Displaying Disk Statistics with WMI via the Win32_LogicalDisk class



Posted by: Jerry Lees
bginfo, VBScript, VBScript Functions, Systems Administration, systems management, Systems administrator tools, systems reporting, Win32_logicaldisk

I recently had to provide the information displayed with BGINFO on a number of systems. Unfortunately, BGInfo only generates a bitmap, so far as I know, so I decided to write a script to generate the information and use this displayed information to send back to the person who requested it.

The function below is a part of the script I mentioned. It retrieves and returns text that represents the total space and the total free space on all the physical hard drives in a system.

You can view all the scripts in this BGINFO series here.

Here is the code:

Function GetDiskInfo(strComputer)
Dim colItems, objItem, address
Dim StrQuery
Dim objWMIService

StrQuery = “SELECT * FROM Win32_logicaldisk”
Set objWMIService = GetObject(”winmgmts:\\” & strComputer & “\root\CIMV2″)
Set colItems = objWMIService.ExecQuery(strQuery,,48)
GetDiskInfo = VbCrLf

For Each objItem in colItems
if objitem.MediaType = 12 Then
GetDiskInfo = GetDiskInfo & vbTab & objItem.Caption & “\ ” & Round((((objItem.size/1024)/1024)/1024),2) & ” GB Total with ” & Round((((objItem.Freespace/1024)/1024)/1024),2) & ” GB free” & ” (” & objitem.filesystem & “)” & VbCrLf
End If
Next
End Function


Mar 10 2009   2:01AM GMT

Writing scripts that use speech with the Windows Speech API



Posted by: Jerry Lees
undocumented windows, SAPI.SpVoice, Sound, Speech API, Office Agent, VBScipt, VBScript Objects

I’ve been looking for ways to make a script speak the information it needs to relay to the user just for fun and, unfortunately the only scripts I could find out there were extremely elaborate onces that use the Microsoft Office Agents. While they fit the bill they were annoying and required Microsoft office components to be installed… that just wouldn’t do.

Then I found the Windows Sound API. It doesn’t require anything at all to be installed and it works fine. The script below is simple and easy to implement in your code. Check it out:

strText = “Hello, there…. can you write code?”

Set objVoice = CreateObject(”SAPI.SpVoice”)
objVoice.Speak strText


Mar 6 2009   3:08PM GMT

Job Hunting in a tight Market



Posted by: Jerry Lees
tips and tricks, IT careers, job hunting

Let’s face it… Job competition is fierce out there in today’s Market. But that doesn’t mean you should give up the search, or that it’s impossible to get that great job. You just have to go back to basics and sell yourself better than the competition!

Here are some great tips from Microsoft for finding and landing the job you want. View the article