Posts Tagged ‘VBS rename’

Server Inventory Script

August 5th, 2009

As a consultant, many times I need to quickly gain information about the Windows servers in an environment. I’ve finally put something together to try and make my life easier. It is a script that opens Microsoft Excel, sets column definitions that seem useful to me, then populates the spreadsheet with a bunch of data.  The data is gathered from every Windows server that is a member of the Active Directory domain you specify.  Specifically, it gathers:

  1. Server Name
  2. Whether the server is online (ping’able) or not
  3. OS
  4. Service Pack
  5. Manufacturer
  6. Model
  7. Serial Number
  8. Whether it is a domain controller
  9. Whether it is a DNS server
  10. Whether it is a DHCP server
  11. Whether it is a WINS server (yes there are still a few of those)
  12. Whether it is a MSCS cluster node
  13. Whether it is an Exchange server
  14. What applications are installed (excluding Security Updates and Hotfixes)
  15. Whether WMI could be connected to

Dependencies

  • Microsoft Excel (any later version is fine)
  • Sysinternals PSTools
  • Admin rights on every server in the domain (Domain Admin rights would be easiest)

I wanted to use WMI exclusively but unfortunately it is very unreliable, therefore the script heavily depends on 2 PSTools (PSInfo and PSService).  You will need to download those and place them in a directory on the PC you run the script from.

Edits

The only lines you need to edit are 15 and 16, where you enter in your domain name (follow the format example!) and the path to your PSTools directory.

'your domain below
strDom = "DC=ACME,DC=COM"
pstoolsPath = "c:\Tools\pstools"

You can download the text of the script here or a zip file with the script here.  I hope others find it helpful.  As always, use this solution at your own risk.  If you have problems with the script, comment on the post and I will help when I have time.

VBS script to rename files

November 19th, 2008

So an upgrade gone wrong at my current client site (no I was not doing the upgrade!) caused about 30 file names to be renamed into a 8.3 format.  This little incident brought operations to a halt in almost every branch!  No pressure for the consultant, right!

VBS script to the rescue.  Just create a input (text) file which has the bad file name, the delimiter of your choice, and the correct file name.  It looks like this (with “#” as my delimiter):

badname1.txt#goodname1.txt
badname2.txt#goodname2.txt
badname3.txt#goodname3.txt
etc....

Place this script in the same folder as the input file, change the Path variable to the path containing the files, then run the script.

Const ForReading = 1
 
On Error Resume Next
 
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.OpenTextFile(".\name_changes.txt", ForReading)
var1 = f1.ReadAll
var2 = Split(var1, vbcrlf)
path = "C:\Test"
For i = 0 To UBound(var2)
                badName = left(var2(i), instr(1, var2(i), "#", 1) -1)
                goodName = right(var2(i), instrrev(var2(i), "#", -1) -1)
                Set filA = fso.GetFile(path & "\" & badName)
                filA.name = goodName
Next
msgbox "All Done!"

By the way, when I showed this script to my son his reply was, “well, that’s not that impressive…”

hmmmm…