Login | |
|
 |
output as hta help - 5/22/2007 2:00:28 AM
|
|
 |
|
| |
faulkkev
Posts: 151
Score: 0
Joined: 11/1/2005
Status: offline
|
How would I go about making the output for this code use hta html type format. the script just pulls local group memberships and local account info. Watered down from bigger script might be some unused code but it works fine minus I would like to improve the output to html. strFilePath = "c:\test.txt" output = "c:\output.txt" Set objFso = CreateObject("Scripting.FileSystemObject") Set objfile = objfso.CreateTextFile(output, True) Set objtextFile = objFSO.OpenTextFile (strFilePath) wscript.echo " To run this script you must have a file on your C: drive named c:\test with a list of computer names. " & "" & " All ouput will be written to c:\output.txt. " & _ " The proper format of the server list is one computer name on top of another " & " Ex. computer 1 " & vbCrLf & _ " computer 2 " Do Until objtextFile.AtEndOfStream strComputer = Trim(objtextFile.ReadLine) if len(strComputer) <> 0 then objfile.writeline "****************************************************************" objfile.writeline " Summary for computer " & strcomputer & " Starts here" objfile.writeline " " objfile.writeline "****************************************************************" on error resume next Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") if err.number = 0 then count = count + 1 get_localaccountinfo(strcomputer) get_localgroupmembers(strcomputer) else noconnect = noconnect + 1 objfile.writeline " " objfile.writeline "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ " objfile.writeline " error connecting to " & strcomputer objfile.writeline "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ " objfile.writeline " " end if end if err.clear loop objfile.writeline " " objfile.writeline " " if count = 0 then objfile.writeline 0 & " Comuters were Successfully Connected to " else objfile.writeline count & " Comuters were Successfully Connected to " end if objfile.writeline " " if noconnect = 0 then objfile.writeline 0 & " Computers were not Successfully Connected to " else objfile.writeline noconnect & " Computers were not Successfully Connected to " end if objfile.close objTextFile.close Wscript.CreateObject("WScript.Shell").Run Output 'result = objfso.OpenTextFile(output, 1).ReadAll 'wscript.echo result '******************************SUB ROUTINES****************************************** '**************SUB GET LOCAL ACCOUNT INFO**************************** sub get_localaccountinfo(strcomputer) on error resume next objfile.writeline " " objfile.writeline " *Local Account Info* " objfile.writeline " " set objArgs=wscript.Arguments Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set UsrObj = GetObject("WinNT://" & strcomputer) if err.Number<>0 then objfile.writeline CHR(13) objfile.writeline "ERROR CONNECTING TO . !" err.clear objfile.writeline CHR(13) wscript.quit end if objfile.writeline "Name: " & vbtab & _ "Full Name: " & vbtab & _ "Description: " & vbtab & _ "Last Login: " & vbtab & _ "Password Expires: " & vbtab & _ "Password Age day(s): " & vbtab & _ "Account Expires: " & vbtab & _ "Password Expired: " & vbtab & _ "Account Disabled: " objfile.writeline " " UsrObj.Filter = Array("user") for each item in UsrObj if item.UserFlags >=65536 then sPasswordExpires = "Never" else sPasswordExpires = item.PasswordExpirationDate end if if item.AccountExpirationDate="" then sAccountExpires = "Never" else sAccountExpires = item.AccountExpirationDate end if If item.AccountDisabled = True Then sAccountDisabled = "Yes" Else sAccountDisabled = "No" End If sfullname = item.fullname sDescription = item.Description sLastLogin = item.LastLogin sPasswordExpired = item.PasswordExpired sPasswordAge = FormatNumber(item.PasswordAge/86400) objfile.writeline item.Name & vbtab & _ sfullname & vbtab & _ sDescription & vbtab & _ sLastLogin & vbtab & _ sPasswordExpires & vbtab & _ sPasswordAge & vbtab & _ sAccountExpires & vbtab & _ sPasswordExpired & vbtab & _ sAccountDisabled Next set usrobj=Nothing objfile.writeline " " objfile.writeline " " end sub '**************SUB GET LOCAL Group MEMBERS**************************** sub get_localgroupmembers(strcomputer) on error resume next objfile.writeline " " objfile.writeline " *Local GROUP MEMBERS* " objfile.writeline " " err.clear Set colgroups = GetObject("WinNT://" & strComputer & ",computer") colGroups.GetInfo colGroups.Filter = Array("Group") For Each objgroup In colGroups objfile.writeline " " & strcomputer & " LOCAL GROUP " & objgroup.name For Each objuser in objgroup.members intcount = intcount + 1 if objuser.name <> "" then user=objuser.name found = true end if if found = true then objfile.writeline " " & user & ", " & objuser.fullname end if if err.number <> 0 then objfile.writeline " " & user end if err.clear next if intcount = 0 then objfile.writeline " Group Is Empty " end if objfile.writeline "" found = false intcount = 0 next objfile.writeline " " err.clear set objuser=Nothing objfile.writeline " " objfile.writeline " " end sub Function WMIDateStringToDate(utcDate) WMIDateStringToDate = CDate(Mid(utcDate, 5, 2) & "/" & _ Mid(utcDate, 7, 2) & "/" & _ Left(utcDate, 4) & " " & _ Mid (utcDate, 9, 2) & ":" & _ Mid(utcDate, 11, 2) & ":" & _ Mid(utcDate, 13, 2)) End Function
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|