Created
January 24, 2013 09:46
-
-
Save proquibas/4619295 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'################ | |
'Creamos los datos de acceso para los servidores | |
'################ | |
strUser = "" | |
strPassword = "" | |
'sHost = "." | |
'################ | |
'Abrimos la lista de ordenadores | |
'################ | |
set objfso = createobject("scripting.filesystemobject") | |
set lista = objfso.opentextfile("C:\lista_servidores.txt") | |
cont_total = 0 | |
cont_ok = 0 | |
cont_err = 0 | |
'################ | |
'Empieza a leer la lista con un bucle hasta fin de archivo. | |
'################ | |
set objfso = createobject("scripting.filesystemobject") | |
set result = objfso.createtextfile("C:\resultado.txt", true) | |
do until lista.atendofstream | |
strComputer = lista.readline ' cogemos en la variable el primer server de la lista | |
strHostname = strComputer | |
ordenador = strComputer | |
cont_total = cont_total + 1 | |
'comprueba el ping | |
If strHostname <> "" Then | |
If CheckStatus(strHostname) = True Then | |
vivo = 0 | |
Else | |
vivo = 1 | |
End If | |
End If | |
row = 2 | |
'comprueba disponibilidad | |
if vivo = 0 then | |
On Error Resume Next | |
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") 'hacemos la conexión al primer server con las credenciales | |
Set objSWbemService = objSWbemLocator.ConnectServer(strComputer, _ | |
"root\cimv2", _ | |
strUser, _ | |
strPassword, _ | |
"MS_409") | |
Set colSettings = objSWbemService.ExecQuery _ | |
("Select * from Win32_Processor") | |
For Each objProcessor In colSettings | |
'result.writeline ordenador & "System Type: " & objProcessor.Architecture | |
'result.writeline ordenador & "Processor: " & objProcessor.Description | |
result.writeline ordenador & " "& objProcessor.AddressWidth | |
Next | |
WScript.Echo "" | |
WScript.Echo "::::::::::::::::::::::::::::::::::" | |
WScript.Echo "El host de destino responde correctamente" | |
WScript.Echo "Importando propiedades de :" & ordenador | |
WScript.Echo "---------------------------------" | |
else | |
'En caso de que falle salta mensaje de error | |
WScript.Echo "" | |
WScript.Echo "*********************************" | |
WScript.Echo "El host de destino NO RESPONDE" | |
WScript.Echo "Host:" & ordenador | |
WScript.Echo "---------------------------------" | |
WScript.Echo "No se ha establecido la conexión" | |
WScript.Echo "" | |
end if | |
vivo = 0 | |
muerto = 0 | |
loop | |
result.close | |
wscript.quit | |
'****************************************** | |
'Extraemos el nombre del nodo | |
'****************************************** | |
Function Nombre_Equipo() | |
strComputer = "." | |
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") | |
Set colItems = objWMI.ExecQuery("Select * from Win32_ComputerSystem",,48) | |
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") | |
For Each objItem In colItems | |
Nombre_Equipo=objItem.Name | |
Exit For | |
Next | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment