Scriptin’1

 
Error Logs
 
‘****************************** ***
‘ Zjisti Errors z logu na stanicich z comps.txt
‘ ******************************* ***

On Error Resume Next

Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("comps.txt", 1, True)
Set objOutputFile = fso.OpenTextFile("vystup.txt", 8, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.ReadLine
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
        ("Select * from Win32_NTLogEvent Where Logfile = ‘System’ and " _
            & "EventType = ‘1’")
For Each objEvent in colLoggedEvents
    objOutputFile.Writeline "Category: " & objEvent.Category
    objOutputFile.Writeline "Computer Name: " & objEvent.ComputerName
    objOutputFile.Writeline "Event Code: " & objEvent.EventCode
    objOutputFile.Writeline "Message: " & objEvent.Message
    objOutputFile.Writeline "Record Number: " & objEvent.RecordNumber
    objOutputFile.Writeline "Source Name: " & objEvent.SourceName
    objOutputFile.Writeline "Time Written: " & objEvent.TimeWritten
    objOutputFile.Writeline "Event Type: " & objEvent.Type
    objOutputFile.Writeline "User: " & objEvent.User
Next
Loop

Scripts

 
Héj,
 
 *  další porcička užitečných scriptíků, tentokrát zaměřených na stroje v síti a pár informací k tomu.
 Věřím, že časem bude scriptíků více.
_______________________________________________________________________________________
‘ Zjisti vyrobce a model pro vyexportovane stroje z ADUC do comps.txt
‘ For more info contact 
http://www.dandr.wz.cz/navstivenka/
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("comps.txt", 1, True)
Set objOutputFile = fso.OpenTextFile("vystup.txt", 8, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.ReadLine
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objItem In colItems
   objOutputFile.WriteLine ("Name: " & objItem.Name)
   objOutputFile.WriteLine ("Manufacturer: " & objItem.Manufacturer)
   objOutputFile.WriteLine ("Model: " & objItem.Model & vbNewLine)
Next
Loop
__________________________________________________________________________________________________________________________
‘ Zjisti nalogovaneho uzivatele na vzdalene stanici
‘ For more info contact  http://www.dandr.wz.cz/navstivenka/
On Error Resume Next
strComputer = "ws_001"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
Wscript.Echo "Logged-on user: " & objComputer.UserName
Next
_________________________________________________________________________________________________________________________
‘ Zjisti volne misto na vsech discich u comps.txt
‘ For more info contact  http://www.dandr.wz.cz/navstivenka/
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("comps.txt", 1, True)
Set objOutputFile = fso.OpenTextFile("vystup.txt", 8, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.ReadLine
Const HARD_DISK = 3
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK & "")
For Each objDisk in colDisks
    objOutputFile.WriteLine "PC: " & strComputer & vbTab & "Disc: " & objDisk.DeviceID
    ‘ID disku muze byt vypsano samostatne, mne se to ale libi u kompu objOutputFile.WriteLine "ID: "& vbTab &  objDisk.DeviceID    
    objOutputFile.WriteLine "Volné místo na Disku: "& vbTab & objDisk.FreeSpace/(1024*1024*1024) & " GB"
    objOutputFile.WriteLine "Total Disk Size: "& vbTab & objDisk.Size/(1024*1024*1024) & " GB"
    objOutputFile.WriteLine "File System: "& vbTab & objDisk.FileSystem & vbNewLine
Next
Loop
 
objOutputFile.Close
Set objOutputFile = fso.OpenTextFile("vystup.txt", 1, True)
 
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "
ok@ok.cz"
objEmail.To = "
drnek@mejl.cz"
objEmail.Subject = "Disks info"
objEmail.Textbody = objOutputFile.ReadAll
objEmail.Configuration.Fields.Item _
    ("
http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
    ("
http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
        "mail1.mejl.cz"
objEmail.Configuration.Fields.Item _
    ("
http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
___________________________________________________________________________
A na závěr se můžete podívat třeba na tyto stránky: