Systems Administration archives - The VBScript Network and Systems Administrator's Cafe

The VBScript Network and Systems Administrator's Cafe:

Systems Administration

Jun 18 2009   3:34PM GMT

A day in the life of a Sysadmin: Check out Microsoft’s Server Quest Game



Posted by: Jerry Lees
Systems Administration, System Administration, Games, Humor

So, I’ve been on call for a week now covering for a co-worker — with a week to go for my turn and got my periodical Technet Flash Email (register here) and thought, “I’ll read up on new technology this morning”. However, my brain’s fried from lack of sleep and I noticed a link to a game from Microsoft… so I thought— “I need some mindless activity right now.”

If you need a mindless activity, and something to laugh at, check out this completely retro Server Quest Game! It will completely remind you of an old school Sierra game when you play the game and it’s well done! So go waste some time—You’ve earned it!

Apr 23 2009   11:28PM GMT

How to Make Your Computer Boot Faster



Posted by: Jerry Lees
tips and tricks, System Administration, Systems Administration, performance tips

I read an interesting article recently that gave some excellent tips at making your computer run faster– without an upgrade! I thought I’d pass some of these tips along and add a few of my own.

First, You can make your computer run faster (and free up space by uninstalling software that you no longer use. You can easily do this with an excellent piece of software called, PC Decrapifier.

The other thing you can do is ensure that you remove applications from your startup that you do not absolutely need. In Vista, you can manage startup applications through Windows Defender. Defender has an integrated tool called Software Explorer that lets you check programs that load at startup and disable anything unnecessary.

You can also access the list of startup applications in either Vista or XP through the Msconfig utility (type “msconfig” into the Run box in the Start menu). Select the Startup tab, then uncheck any applications you think might be slowing your startup.

Consult an online database of startup processes, such as Sysinfo, to find out what the process may be– keeping in mind that it may not be 100% accurate.

If you’re serious about shaving every last second of startup time, dig into the Boot tab in the Msconfig utility, which controls the settings for the boot.ini file. Generally, users should tread carefully when tinkering with boot.ini, because one slip up and you can have a non-bootable computer. But one easy edit is to check the “/noguiboot” option to time by skipping the Windows startup animation.

Another useful tip is to clean up the registry. There are various applications out there, Free programs such as CCleaner and Glary Utilities, as well as more fully featured software such as System Mechanic (System Mechanic just simply can’t be beat in my opinion, the others are free but sometimes don’t do as complete a job) are available for download online and will scrub the registry for “keys” left over from old applications no longer resident on your machine.

Doing some or all of these will no doubt result in some extra free space on your computer as well as some extra free time– who knows, you may not even have time to get that first cup of coffee in before your computer is totally logged in. ;-)

Enjoy!


Apr 13 2009   3:18PM GMT

Finding the owner of a process remotely with VBScript via the Win32_process class



Posted by: Jerry Lees
WMI, Windows Management Interface, win32_process, System Administration, Systems Administration, Administration tools, VBScript, VBScript Functions, Functions

 Recently I had an issue where I needed to find the user running a series of processes on a large number of servers. Initially, it was a long process of logging onto each server then opening task manager and sorting by process name. After about 5 servers, I realized it was going to take hours to sort out the users running the processes… so I spent 30 minutes not preforming this process and wrote a script to do the rest of the work in less than a minute!

The function below uses the Win32_Process WMI class to enumerate processes running on a server that are named the same as the process name you give it. It then outputs the name of the user running the process.

Below is the function… Enjoy!

 Function FindProcessOwner( StrComputer1, ProcessName)

Dim objWMIService, colItems, objItem, Username, Domain

On Error Resume Next
‘ error control block
Set objWMIService = GetObject(”winmgmts:{impersonationLevel=impersonate}//” & strComputer1 & “\root\cimv2″)
If Err.Number <> 0 Then
WScript.Echo “An Error Occured (” & StrComputer1 & “): ” & Err.Description
End If
Set colItems = objWMIService.ExecQuery (”Select * from Win32_Process Where Name = ‘” & ProcessName & “‘”)
WScript.Echo “Searching for processes on ” & StrComputer1 & “.”
WScript.Echo colItems.count & ” processes found.”
For Each objItem in colItems
objItem.getowner Username, Domain
FindProcessOwner = FindProcessOwner & VbCrLf & strComputer1 & “: ” & objItem.name &_
“(PID: ” & objItem.processid & “) the owner is: ” & Domain & “\” & Username
Next
On Error GoTo 0
End Function


Apr 9 2009   4:23PM GMT

Writing a BGINFO like Script: Displaying IP Address 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 IP address settings for the network cards installed in a system.

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

Here is the code:

Function GetIPAddresses(strComputer)
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.ipaddress
IP = replace(address,”:”,””)
‘IP = Replace(IP,vbnull,”No IP Assigned”)
GetIPAddresses = GetIPAddresses & vbTab & mid(objItem.caption,InStr(objItem.caption,”]”)+2) & “: ” & IP & vbcrLF
Next
Next
End Function


Apr 7 2009   4:23PM GMT

Writing a BGINFO like Script: Displaying Operating System Information with WMI via the Win32_OperatingSystem 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 operating system and service pack information installed on a system.

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

Here is the code:

Function GetOSVersion(strComputer)
Dim colItems, objItem, address
Dim StrQuery
Dim objWMIService
GetOSVersion = VbCrLfStrQuery = “SELECT * FROM Win32_OperatingSystem”
Set objWMIService = GetObject(”winmgmts:\\” & strComputer & “\root\CIMV2″)
Set colItems = objWMIService.ExecQuery(strQuery,,48)

 

For Each objItem in colItems
GetOSVersion = GetOSVersion & vbTab & replace(objItem.caption,”(R)”,””) & VbCrLf
GetOSVersion = GetOSVersion & vbTab & “Service Pack ” & objitem.ServicePackMajorVersion & VbCrLf
Next
End Function


Apr 2 2009   1:23PM GMT

Writing a BGINFO like Script: Displaying Page File information with WMI via the Win32_Pagefile 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 page file space allocated in a system.

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

Here is the code:

Function GetPageFile(strComputer)
Dim colItems, objItem, address
Dim StrQuery
Dim objWMIService
GetPageFile = VbCrLfStrQuery = “SELECT * FROM Win32_PageFile”
Set objWMIService = GetObject(”winmgmts:\\” & strComputer & “\root\CIMV2″)
Set colItems = objWMIService.ExecQuery(strQuery,,48)

 

For Each objItem in colItems
GetPageFile = GetPageFile & vbTab & ((objItem.filesize/1024)/1024) & ” Mb” & vbcrlf
Next
End Function


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 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