' MAILER ' Ultima modifica 04062013-rev0 dev@gfsolone.com ' Vedi: http://public.gfsolone.com/wiki/doku.php?id=vbs:alertmailer Set WshNetwork = WScript.CreateObject("WScript.Network") Set objNTInfo = CreateObject("WinNTSystemInfo") Set objFSO = CreateObject("scripting.filesystemobject") dim strFrom, strAlert, strSubject, strTextBody Set objArgs = WScript.Arguments strFrom = objArgs(0) strAlert = objArgs(1) strSubject = objArgs(2) strTextBody = objArgs(3) ' Rilevamento IP locale / VPN della macchina ' Vedi wiki: http://public.gfsolone.com/wiki/doku.php?id=vbs:localhostinfo dim NIC1, Nic, StrIP, CompName Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration") For Each Nic in NIC1 if Nic.IPEnabled then StrIP = Nic.IPAddress(i) CompName = WshNetwork.Computername Dim WMI, Configs, Config, Adapters, Adapter Set WMI = GetObject("winmgmts:{impersonationlevel=impersonate}root/cimv2") Set Configs = WMI.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled=True") For Each Config In Configs Set Adapters = WMI.AssociatorsOf("Win32_NetworkAdapterConfiguration.Index=" & Config.Index, "Win32_NetworkAdapterSetting") For Each Adapter In Adapters VPNIP = Config.IPAddress(0) Next Next 'Debug: informazioni mostrate in msgbox (togliere i commenti per la verifica) 'MsgBox "IP Address: "&StrIP & vbNewLine _ '& "VPN IP Address: "&VPNIP & vbNewLine _ '& "Computer Name: "&CompName ,4160,"IP Address and Computer Name" 'wscript.quit end if next ' SendMail GSolone 20121122 rev2 con SMTP Esterno ' Vedi wiki: http://public.gfsolone.com/wiki/doku.php?id=vbs:sendmail ' La modifica allo script permette l'utilizzo di un server SMTP esterno passando le credenziali di autenticazione basic, porta 25. 'strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" ) Set objMessage = CreateObject("CDO.Message") 'debug objMessage.From = "mittente@localhost.tld" 'debug objMessage.To = "destinatario@localhost.tld" 'debug MsgBox "From rilevato: " & strFrom & vbNewLine & "To rilevato: "& strAlert & vbNewLine objMessage.From = strFrom objMessage.To = strAlert objMessage.Subject = strSubject objMessage.TextBody = strTextBody & vbCRLF & vbCRLF & "------------------------" & vbCRLF & "Source Host: " & CompName & vbCRLF & "Local IP: " & StrIP objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.localhost.tld" objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mittente@localhost.tld" objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password" objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 objMessage.Configuration.Fields.Update objMessage.Send