Wednesday, June 25, 2008

Batch File to Backup SQL Server

Posted by Brian Bohanon

No budget for a Backup Exec SQL agent license? Save the following as a batch file and run it as a scheduled task to back up a database. The following items must be changed in this script to appropriate values:

  1. -SMYSERVERNAME - MYSEVERNAME needs to be the SQL server name (note there is no space between -S and MYSERVERNAME)
  2. MYSQLINSTANCE - this is the SQL instance name
  3. MYDATABASENAME - the name of the database to be backed up
  4. BACKUPDIRECTORY - the directory name on the SQL server to put the backup file in
  5. FILENAME.bak - this is the name of the backup file
  6. MyBackupServer - name of the remote server to map a drive


@ECHO OFF

SET CMD_PATH=%SYSTEMROOT%\system32\cmd.exe

%CMD_Path% /c ""C:\Program Files\Microsoft SQL Server\90\Tools\Binn\osql" ^ -E ^ -SMYSERVERNAME\MYSQLINSTANCE ^ -Q"BACKUP DATABASE MYDATABASENAME TO DISK = ^ 'C:\BACKUPDIRECTORY\FILENAME.bak' WITH INIT"

REM Map a drive to a remote computer to copy it off host

%CMD_PATH% /c "net use t: "\\MyBackupServer\d$\Services Backups\Backup""

REM Robocopy is a free tool from Microsoft to copy and replace the file

%CMD_Path% /c "robocopy.exe "C:\BACKUPDIRECTORY" "T:" /E /ZB /COPYALL ^ /LOG:"c:\BACKUPDIRECTORY\Backup.log"

REM remove the drive mapping

%CMD_PATH% /c "net use t: /delete"

Monday, June 23, 2008

Yugma - Free Web Conferencing

Posted by Brian Bohanon

Yugma is the newest, in a long line of web conferencing services. Yugma is free, offering the availability to upgrade from a personal (free) to a premium account with all of the bells and whistles. The differences in the two levels of accounts include:

  • Free is limited to 10 attendees
  • Personal doesn't allow for passing mouse/keyboard controls
  • Can't change presenter
  • Can't use annotation tools (whiteboard, screen marking, etc.)
  • No online storage
  • No tech support (online help only)

With all of that, the free version is still very cool because you get the desktop sharing, chat, and file sharing. These are good options for free and are very useful for those of us that just need somewhere to point people for quick, free desktop sharing.



Test for Drop.io

Posted by Brian Bohanon

http://drop.io is a website that allows for ad-hoc or planned social workspaces. This site will store several types of media. This is a test for embedding that information. A new post will be added after I have figured out how to fully utilize it.


drop.io: simple private sharing

Wednesday, June 18, 2008

VBScript to get Services from Servers

Posted by Brian Bohanon

The script below was written to parse a selected text file containing server names, loop through the list, create a new worksheet for each server and put the services into that worksheet. This can be done for as many servers as needed. At the end of the routine, the script saves the Excel file to the user's desktop and closes the application. I have run it several times and it has worked without fail so far. This is a nice script to gather all of the relevant service information for all of the computers in an environment. This information can be invaluable during recovery of a system.


'*********************************************************************************
'Script to remotely inventory installed services from a list of machines from a
' text file, put the services into an Excel workbook, and then save the
' workbook to the desktop.
' Created by: Brian Bohanon
' Created: 6/17/2008
'*********************************************************************************

Option Explicit

Dim arrFileLines()
Dim tst
Dim i, j, k, l
Dim objFSO, objFile, objDialog, objExcel, objWMIService, objService, objWorkbook
Dim WshShell
Dim colServices
Dim srcFileName 'source file
Dim intResult
Dim strComputer 'computer to inventory

'Constants
Const xlLeft = -4131
Const xlHorizontal = -4128

'Set Objects
Set objExcel = CreateObject("Excel.Application")
Set objDialog = CreateObject("UserAccounts.CommonDialog")
Set WshShell = WScript.CreateObject("WScript.Shell")

'Open the source file that contains the list of computers
objDialog.Filter = "Text Files|*.txt"
objDialog.InitialDir = WshShell.SpecialFolders("Desktop")
intResult = objDialog.ShowOpen

If intResult = 0 Then
Wscript.Quit
Else
'Set selected file to srcFileName
srcFileName = objDialog.FileName

i = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(srcFileName, 1)
Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close

'*********************************************************************************
' Create a new Excel Workboot
'*********************************************************************************
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add()

'*********************************************************************************
'Loop through the array of computers, create a worksheet with the computer name,
' get the list of services,
' and write out the services to the excel sheet
'*********************************************************************************

k = 3
objExcel.Worksheets("Sheet1").Delete
objExcel.Worksheets("Sheet2").Delete

For l = Ubound(arrFileLines) to LBound(arrFileLines) Step -1
On Error Resume Next
if k = 3 then
objExcel.Worksheets("Sheet" & k).Activate
objExcel.Worksheets("Sheet" & k).Name = arrFileLines(l)
else
objExcel.Worksheets.Add
objExcel.Worksheets("Sheet" & k).Activate
objExcel.Worksheets("Sheet" & k).Name = arrFileLines(l)
end if

'*********************************************************************************
'Services Information
'*********************************************************************************

'Select server to inventory
Set objWMIService = GetObject("winmgmts:\\" & arrFileLines(l) & "\root\cimv2")
Set colServices = objWMIService.ExecQuery("Select * From Win32_Service")

i = 1
j = 1

'Column headers
objExcel.Cells(i, j).Value = "Service"
objExcel.Cells(i, j).Font.Bold = TRUE
j = j + 1
objExcel.Cells(i, j).Value = "Status"
objExcel.Cells(i, j).Font.Bold = TRUE
j = j + 1
objExcel.Cells(i, j).Value = "Start Mode"
objExcel.Cells(i, j).Font.Bold = TRUE
j = j + 1
objExcel.Cells(i, j).Value = "Start Name"
objExcel.Cells(i, j).Font.Bold = TRUE
j = j + 1
objExcel.Cells(i, j).Value = "Path Name"
objExcel.Cells(i, j).Font.Bold = TRUE

'Services data
For Each objService in colServices
i = i + 1
j = 1
objExcel.Cells(i, j) = objService.Name
j = j + 1
objExcel.Cells(i, j) = objService.State
'Show stopped services in Red
If objService.State = "Stopped" Then
objExcel.Cells(i, j).Font.ColorIndex = 3
End If
j = j + 1
objExcel.Cells(i, j) = objService.StartMode
j = j + 1
objExcel.Cells(i, j) = objService.StartName
j = j + 1
objExcel.Cells(i, j) = objService.PathName
Next

' Autofit the first column to fit the longest service name
objExcel.Columns("A:Z").EntireColumn.AutoFit
objExcel.Columns("A:Z").HorizontalAlignment = xlLeft

k = k + 1
Next

'Save the workbook to the desktop
objWorkbook.SaveAs(WshShell.SpecialFolders("Desktop") & "\ServerServices_" & Month(Date()) & "_" & Day(Date()) & "_" & Year(Date()) & ".xls")

'Close Excel
objExcel.Quit

End If

'*********************************************************************************
'Cleanup
'*********************************************************************************

'Cleanup objects

Set objExcel = nothing
Set objFSO = nothing
Set objWMIService = nothing
Set objService = nothing
Set objFile = nothing
Set objDialog = nothing
Set WshShell = nothing

'Inform the user that the process is complete
Wscript.Echo("Finished")

Wscript.Quit 0

Tuesday, June 17, 2008

Scribd - Online Document Storage

Posted by Brian Bohanon

This is a really neat tool that I stubmled on while trying to figure out how to display code in an iFrame for my blog. In my previous post (VBSScript to Inventory Windows Computer) I used this very tool to display the code from a very long script.

This is a very useful tool that addresses a specific need for me. This allows me to post documents for free and embed them into my blog.

Scribd - http://www.scribd.com

Below is a sample document that I uploaded and embeded into my blog.

Read this document on Scribd: Installing the Cisco Attendant Console


VBSScript to Inventory Windows Computer

Posted by Brian Bohanon

As part of a goal for 2008, I wanted to get a list of services running on a given Windows computer, including the accounts used and the startup mode. Once that script was written, it was much too easy to continue gathering relevant information for a system. The script below is the result.


'******************************************************************************************
'Script to remotely inventory a machine
' Created by: Brian Bohanon
' Created: 6/11/2008
'******************************************************************************************

'Get the computer name from user to begin processing
strComputer = InputBox("Computer to Inventory", "Computer Name")

'Initialize counter
i = 0

'Declare Constants
Const xlLeft = -4131
Const xlHorizontal = -4128

'Declare Objects
Set objExcel = CreateObject("Excel.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

'Initialize collections
Set colBIOS = objWMIService.ExecQuery("Select * from Win32_BIOS")
Set colDisks = objWMIService.ExecQuery("Select * from Win32_LogicalDisk")
Set colDiskDrives = objWMIService.ExecQuery("Select * from Win32_DiskDrive")
Set colDrives = objFSO.Drives
Set colNet = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter")
Set colOSItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
Set colPrintItems = objWMIService.ExecQuery("Select * from Win32_Printer")
Set colProcItems = objWMIService.ExecQuery("Select * from Win32_Processor")
Set colQuickFixes = objWMIService.ExecQuery("Select * from Win32_QuickFixEngineering")
Set colSCSIItems = objWMIService.ExecQuery("Select * from Win32_SCSIController")
Set colServices = objWMIService.ExecQuery("Select * From Win32_Service")
Set colSettings = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
Set colSoftware = objWMIService.ExecQuery("Select * from Win32_Product")
Set colVideo = objWMIService.ExecQuery("Select * from Win32_VideoController")

'*******************************************************************************************
' Create a new and blank spreadsheet
'*******************************************************************************************
objExcel.Visible = True
objExcel.Workbooks.Add

'Setup the workbook
do while i <> 2
objExcel.Worksheets.Add
i = i + 1
loop

'Create Sheet named %computername% for computer name, os, install date, general information
objExcel.Worksheets("Sheet5").Name = strComputer
'Create Sheet named software
objExcel.Worksheets("Sheet4").Name = "Software"
'Create Sheet named services
objExcel.Worksheets("Sheet1").Name = "Services"
'Create Sheet named hardware - e.g. disk drives, memory, processor
objExcel.Worksheets("Sheet2").Name = "Hardware"
'Create Sheet named printers
objExcel.Worksheets("Sheet3").Name = "Printers"

'*****************************************************************************************
'Computer information
'*****************************************************************************************

'start the counter for all of the loops
i = 1 'row counter
j = 1 'column counter

' Section header
objExcel.Cells(i, j).Value = "Computer Information"
objExcel.Cells(i, j).Font.Bold = TRUE

i = i + 1

objExcel.Cells(i, j).Value = "Computer Name: "
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + i

objExcel.Cells(2, 2).Value = strComputer

'Get OS information

i = i + 2
j = 1

For Each objOSItem in colOSItems
objExcel.Cells(i, j).Value = "Operating System:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = objOSItem.Caption

i = i + 1
j = j - 1

objExcel.Cells(i, j).Value = "Description:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = objOSItem.Description

i = i + 1
j = j - 1

objExcel.Cells(i, j).Value = "InstallDate:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = objOSItem.InstallDate

i = i + 1
j = j - 1

objExcel.Cells(i, j).Value = "Organization:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = objOSItem.Organization

i = i + 1
j = j - 1

objExcel.Cells(i, j).Value = "RegisteredUser:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = objOSItem.RegisteredUser

i = i + 1
j = j - 1

objExcel.Cells(i, j).Value = "SerialNumber:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = objOSItem.SerialNumber

i = i + 1
j = j - 1

objExcel.Cells(i, j).Value = "ServicePackMajorVersion:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = "SP " & objOSItem.ServicePackMajorVersion

i = i + 1
j = j - 1

objExcel.Cells(i, j).Value = "ServicePackMinorVersion:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = objOSItem.ServicePackMinorVersion

i = i + 1
j = j - 1

objExcel.Cells(i, j).Value = "Version:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = objOSItem.Version

i = i + 1
j = j - 1

objExcel.Cells(i, j).Value = "WindowsDirectory:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = objOSItem.WindowsDirectory

i = i + 1
j = j - 1
Next

Set objOSItem = nothing

i = i + 1

'Section header
objExcel.Cells(i, j).Value = "Physical Machine Information"
objExcel.Cells(i, j).Font.Bold = TRUE

i = i + 1

'Insert hardware serial number
For each objBIOS in colBIOS
objExcel.Cells(i, j).Value = "Serial Number"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = objBIOS.SerialNumber
Next

Set objBIOS = nothing

i = i + 1
j = 1

'Physical Machine information
For Each objSetting in colSettings
objExcel.Cells(i, j).Value = "Manufacturer:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = objSetting.Manufacturer

i = i + 1
j = j - 1

i = i + 1
j = 1

objExcel.Cells(i, j).Value = "Model:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = objSetting.Model

i = i + 1
j = j - 1

objExcel.Cells(i, j).Value = "System Type:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = objSetting.SystemType
Next

Set objSetting = nothing

' Autofit the columns
objExcel.Columns("A:Z").EntireColumn.AutoFit
objExcel.Columns("A:Z").HorizontalAlignment = xlLeft


'*************************************************************************************
'Software Information
'*************************************************************************************

'Activate the Software worksheet
objExcel.Worksheets("Software").Activate

i = 1
j = 1

objExcel.Cells(i, j) = "Software"
objExcel.Cells(i, j).Font.Bold = TRUE

i = i + 1

objExcel.Cells(i, j) = "Caption:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Name:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Version:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Description:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Vendor:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Identiying Number:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Install Date:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Install Location:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Package Cache:"
objExcel.Cells(i, j).Font.Bold = TRUE

i = i + 1
j = 1

For Each objSoftware in colSoftware
objExcel.Cells(i, j) = objSoftware.Caption

j = j + 1

objExcel.Cells(i, j) = objSoftware.Name

j = j + 1

objExcel.Cells(i, j) = objSoftware.Version

j = j + 1

objExcel.Cells(i, j) = objSoftware.Description

j = j + 1

objExcel.Cells(i, j) = objSoftware.Vendor

j = j + 1

objExcel.Cells(i, j) = objSoftware.IdentifyingNumber

j = j + 1

objExcel.Cells(i, j) = objSoftware.InstallDate2

j = j + 1

objExcel.Cells(i, j) = objSoftware.InstallLocation

j = j + 1

objExcel.Cells(i, j) = objSoftware.PackageCache

j = 1
i = i + 1
Next

Set objSoftware = nothing

i = i + 1
j = 1

'Section header
objExcel.Cells(i, j) = "Installed Hotfixes"
objExcel.Cells(i, j).Font.Bold = TRUE

i = i + 1

'Column headers
objExcel.Cells(i, j) = "Hot Fix ID:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Description:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Installation Date:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Service Pack Level:"
objExcel.Cells(i, j).Font.Bold = TRUE


'Hotfix data
For Each objQuickFix in colQuickFixes
i = i + 1
j = 1

If objQuickFix.HotFixID = "File 1" Then
objExcel.Cells(i, j) = objQuickFix.ServicePackInEffect
Else
objExcel.Cells(i, j) = objQuickFix.HotFixID
End If

j = j + 1

objExcel.Cells(i, j) = objQuickFix.Description

j = j + 1

objExcel.Cells(i, j) = objQuickFix.InstalledBy

j = j + 1

objExcel.Cells(i, j) = objQuickFix.ServicePackInEffect
Next

Set objQuickFix = nothing

' Autofit the columns
objExcel.Columns("A:Z").EntireColumn.AutoFit
objExcel.Columns("A:Z").HorizontalAlignment = xlLeft

'*************************************************************************************
'Services Information
'*************************************************************************************

'Activate the services worksheet
objExcel.Worksheets("Services").Activate

i = 1
j = 1

'Column headers
objExcel.Cells(i, j).Value = "Service"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = "Status"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = "StartMode"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = "StartName"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j).Value = "PathName"
objExcel.Cells(i, j).Font.Bold = TRUE

'Services data
For Each objService in colServices
i = i + 1
objExcel.Cells(i, 1) = objService.Name
objExcel.Cells(i, 2) = objService.State
objExcel.Cells(i, 3) = objService.StartMode
objExcel.Cells(i, 4) = objService.StartName
objExcel.Cells(i, 5) = objService.PathName
if objService.State = "Stopped" then
objExcel.Cells(i, 2).Font.ColorIndex = 3
end if
Next

Set objService = nothing

' Autofit the first column to fit the longest service name
objExcel.Columns("A:Z").EntireColumn.AutoFit
objExcel.Columns("A:Z").HorizontalAlignment = xlLeft

'*****************************************************************************************
'Hardware Section
'*****************************************************************************************

'Activate the hardware worksheet
objExcel.Worksheets("Hardware").Activate

i = 1
j = 1

'Section header
objExcel.Cells(i, j) = "Logical Drives"
objExcel.Cells(i, j).Font.Bold = TRUE

i = i + 1
j = 1

'Column headers
objExcel.Cells(i, j) = "Drive letters:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Volume Name:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Description:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "File System:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Total Size (GB):"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Free Space (GB):"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Volume Serial Number:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Compressed:"
objExcel.Cells(i, j).Font.Bold = TRUE


i = i + 1
j = 1

'Logical disk data
For each objDisk in colDisks
objExcel.Cells(i, j) = objDisk.DeviceID

j = j + 1

objExcel.Cells(i, j) = objDisk.VolumeName

j = j + 1

objExcel.Cells(i, j) = objDisk.Description

j = j + 1

objExcel.Cells(i, j) = objDisk.FileSystem

j = j + 1

disk_size = objDisk.Size / 1073741824
objExcel.Cells(i, j) = int(disk_size)

j = j + 1

disk_free = objDisk.FreeSpace / 1073741824
objExcel.Cells(i, j) = int(disk_free)

j = j + 1

objExcel.Cells(i, j) = objDisk.VolumeSerialNumber

j = j + 1

objExcel.Cells(i, j) = objDisk.Compressed

j = 1
i = i + 1
Next

Set objDisk = nothing

j = 1
i = i + 1

'Section header
objExcel.Cells(i, j) = "Physical Drives"
objExcel.Cells(i, j).Font.Bold = TRUE

i = i + 1
j = 1

'Column headers
objExcel.Cells(i, j) = "Caption:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Device ID:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Index:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Interface Type:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Manufacturer:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Media Loaded:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Media Type:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Model:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Partitions:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "SCSI Bus:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "SCSI Logical Unit:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "SCSI Port:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "SCSI TargetId:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Sectors Per Track:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Signature:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Size (GB):"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Status:"
objExcel.Cells(i, j).Font.Bold = TRUE

'Physical disk data
For each objDiskDrive in colDiskDrives

i = i + 1
j = 1

objExcel.Cells(i, j) = objDiskDrive.Caption

j = j + 1

objExcel.Cells(i, j) = objDiskDrive.DeviceID

j = j + 1

objExcel.Cells(i, j) = objDiskDrive.Index

j = j + 1

objExcel.Cells(i, j) = objDiskDrive.InterfaceType

j = j + 1

objExcel.Cells(i, j) = objDiskDrive.Manufacturer

j = j + 1

objExcel.Cells(i, j) = objDiskDrive.MediaLoaded

j = j + 1

objExcel.Cells(i, j) = objDiskDrive.MediaType

j = j + 1

objExcel.Cells(i, j) = objDiskDrive.Model

j = j + 1

objExcel.Cells(i, j) = objDiskDrive.Partitions

j = j + 1

objExcel.Cells(i, j) = objDiskDrive.SCSIBus

j = j + 1

objExcel.Cells(i, j) = objDiskDrive.SCSILogicalUnit

j = j + 1

objExcel.Cells(i, j) = objDiskDrive.SCSIPort

j = j + 1

objExcel.Cells(i, j) = objDiskDrive.SCSITargetId

j = j + 1

objExcel.Cells(i, j) = objDiskDrive.SectorsPerTrack

j = j + 1

objExcel.Cells(i, j) = objDiskDrive.Signature

j = j + 1

diskDrive_size = objDiskDrive.Size / 1073741824
objExcel.Cells(i, j) = int(diskDrive_size)

j = j + 1

objExcel.Cells(i, j) = objDiskDrive.Status

Next

Set objDiskDrive = nothing

'Get SCSI Controller

j = 1
i = i + 2

'Section header
objExcel.Cells(i, j) = "SCSI Information"
objExcel.Cells(i, j).Font.Bold = TRUE

i = i + 1
j = 1

'Column headers
objExcel.Cells(i, j) = "Name:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Device ID:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Driver Name:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "PNP Device ID:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Protocol Supported:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Status Information:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Configuration Manager Error Code:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Configuration Manager User Configuration:"
objExcel.Cells(i, j).Font.Bold = TRUE


'SCSI controller data
For Each objSCSIItem in colSCSIItems
i = i + 1
j = 1

objExcel.Cells(i, j) = objSCSIItem.Name

j = j + 1

objExcel.Cells(i, j) = objSCSIItem.DeviceID

j = j + 1

objExcel.Cells(i, j) = objSCSIItem.DriverName

j = j + 1

objExcel.Cells(i, j) = objSCSIItem.PNPDeviceID

j = j + 1

objExcel.Cells(i, j) = objSCSIItem.ProtocolSupported

j = j + 1

objExcel.Cells(i, j) = objSCSIItem.StatusInfo

j = j + 1

objExcel.Cells(i, j) = objSCSIItem.ConfigManagerErrorCode

j = j + 1

objExcel.Cells(i, j) = objSCSIItem.ConfigManagerUserConfig
Next

Set objSCSIItem = nothing

'Get BIOS information

j = 1
i = i + 2

'Section header
objExcel.Cells(i, j) = "BIOS Information"
objExcel.Cells(i, j).Font.Bold = TRUE

i = i + 1
j = 1

'Column header
objExcel.Cells(i, j) = "Manufacturer:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Name:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Release Date:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Version:"
objExcel.Cells(i, j).Font.Bold = TRUE

'BIOS data
For each objBIOS in colBIOS
i = i + 1
j = 1

objExcel.Cells(i, j) = objBIOS.Manufacturer

j = j + 1

objExcel.Cells(i, j) = objBIOS.Name

j = j + 1

objExcel.Cells(i, j) = objBIOS.ReleaseDate

j = j + 1

objExcel.Cells(i, j) = objBIOS.Version
Next

Set objBIOS = nothing

'Get Processor information

j = 1
i = i + 2

'Section header
objExcel.Cells(i, j) = "Processor Information"
objExcel.Cells(i, j).Font.Bold = TRUE

i = i + 1
j = 1

'Column headers
objExcel.Cells(i, j) = "Name:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Manufacturer:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Current Clock Speed (MHz):"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "L2 Cache Size (MB):"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Architecture:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Address Width (bits):"
objExcel.Cells(i, j).Font.Bold = TRUE

'Processor data
For Each objProcItem in colProcItems
i = i + 1
j = 1

objExcel.Cells(i, j) = objProcItem.Name

j = j + 1

objExcel.Cells(i, j) = objProcItem.Manufacturer

j = j + 1

objExcel.Cells(i, j) = objProcItem.CurrentClockSpeed

j = j + 1

objExcel.Cells(i, j) = objProcItem.L2CacheSize

j = j + 1

objExcel.Cells(i, j) = objProcItem.Architecture

j = j + 1

objExcel.Cells(i, j) = objProcItem.AddressWidth

Next

Set objProcItem = nothing

'Get Memory Information

j = 1
i = i + 2

'Section header
objExcel.Cells(i, j) = "Physical Memory Information"
objExcel.Cells(i, j).Font.Bold = TRUE

i = i + 1
j = 1

'Column header
objExcel.Cells(i, j) = "Total Physical Memory (MB):"
objExcel.Cells(i, j).Font.Bold = TRUE

'Physical memory data
For Each objSetting in colSettings
i = i + 1
j = 1

phys_ram = objSetting.TotalPhysicalMemory / 1048576
objExcel.Cells(i, j) = int(phys_ram)
Next

Set objSetting = nothing

'Get Video Information

j = 1
i = i + 2

'Section header
objExcel.Cells(i, j) = "Video Card Information"
objExcel.Cells(i, j).Font.Bold = TRUE

i = i + 1
j = 1

'Column header
objExcel.Cells(i, j) = "Name:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Description:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Driver Version:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Video Memory (MB):"
objExcel.Cells(i, j).Font.Bold = TRUE

'Video card data
For Each objVideo in colVideo
i = i + 1
j = 1

objExcel.Cells(i, j) = objVideo.Caption

j = j + 1

objExcel.Cells(i, j) = objVideo.Description

j = j + 1

objExcel.Cells(i, j) = objVideo.DriverVersion

j = j + 1

video_ram = objVideo.AdapterRAM / 1048576
objExcel.Cells(i, j) = int(video_ram)

Next

Set objVideo = nothing

'Get Network Adapter Information

j = 1
i = i + 2

'Section header
objExcel.Cells(i, j) = "NIC Information"
objExcel.Cells(i, j).Font.Bold = TRUE

'Column header
i = i + 1
j = 1

objExcel.Cells(i, j) = "Name:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "MAC Address:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Manufacturer:"
objExcel.Cells(i, j).Font.Bold = TRUE

'Network card data
For Each objNet in colNet

If objNet.MACAddress <> "" Then
i = i + 1
j = 1

objExcel.Cells(i, j) = objNet.Name

j = j + 1

objExcel.Cells(i, j) = objNet.MACAddress

j = j + 1

objExcel.Cells(i, j) = objNet.Manufacturer
End if
Next

Set objNet = nothing

' Autofit the first column to fit the longest name
objExcel.Columns("A:Z").EntireColumn.AutoFit
objExcel.Columns("A:Z").HorizontalAlignment = xlLeft

'******************************************************************************************
'Printers Section
'******************************************************************************************

objExcel.Worksheets("Printers").Activate

i = 1
j = 1

'Section header
objExcel.Cells(i, j) = "Printer Information"
objExcel.Cells(i, j).Font.Bold = TRUE

'Column Headers
i = i + 1
j = 1

objExcel.Cells(i, j) = "Default:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Name:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Server Name:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Share Name:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Driver Name:"
objExcel.Cells(i, j).Font.Bold = TRUE

j = j + 1

objExcel.Cells(i, j) = "Port Name:"
objExcel.Cells(i, j).Font.Bold = TRUE

'List printer objects
For Each objPrintItem in colPrintItems
i = i + 1
j = 1

objExcel.Cells(i, j) = objPrintItem.Default

j = j + 1

objExcel.Cells(i, j) = objPrintItem.Name

j = j + 1

objExcel.Cells(i, j) = objPrintItem.ServerName

j = j + 1

objExcel.Cells(i, j) = objPrintItem.ShareName

j = j + 1

objExcel.Cells(i, j) = objPrintItem.DriverName

j = j + 1

objExcel.Cells(i, j) = objPrintItem.PortName
Next

Set objPrintItem = nothing

' Autofit the first column to fit the longest name
objExcel.Columns("A:Z").EntireColumn.AutoFit
objExcel.Columns("A:Z").HorizontalAlignment = xlLeft

'Activate the Main worksheet
objExcel.Worksheets(strComputer).Activate

'Cleanup objects
Set objExcel.Quit
Set objExcel = nothing
Set objFSO = nothing
Set objWMIService = nothing

'Initialize collections
Set colBIOS = nothing
Set colDisks = nothing
Set colDiskDrives = nothing
Set colDrives = nothing
Set colNet = nothing
Set colOSItems = nothing
Set colPrintItems = nothing
Set colProcItems = nothing
Set colQuickFixes = nothing
Set colSCSIItems = nothing
Set colServices = nothing
Set colSettings = nothing
Set colSoftware = nothing
Set colVideo = nothing

'Inform the user that the process is complete
wscript.echo("Finished")

Wscript.Quit 0

  © Blogger template 'A Click Apart' by Ourblogtemplates.com 2008

Back to TOP