Afficher la configuration réseau d’un serveur distant en VBScript

Devez-vous vraiment installer un VPN sur votre ordinateur ou votre smartphone?

Si vous téléchargez films, séries, MP3, ebooks et jeux illégalement, si vous voulez surfer sur Internet de façon anonyme sans que le gouvernement, votre FAI ou votre employeur soit au courant ... OUI installer un VPN est définitivement une bonne idée !

> Choisissez le meilleur VPN et apprenez à l'utiliser en 5 mn !

Anonymat NordVPN

Ce script VBS vous permettra de visualiser la configuration IP de chacune des interfaces réseaux d’un serveur Windows distant.

Afficher la configuration réseau d’un serveur distant en VBScript

Créez un nouveau fichier portant l’extension .vbs, ouvez-le avec un éditeur de texte comme PSPad et copiez le code suivant dans le fichier.

strComputer = inputbox( "Nom du serveur", "Input" )
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
n = 1
For Each objAdapter in colAdapters
WScript.Echo "Carte réseau n° " & n
WScript.Echo "Description: " & objAdapter.Description
WScript.Echo "MAC address: " & objAdapter.MACAddress
WScript.Echo "Host name: " & objAdapter.DNSHostName
If Not IsNull(objAdapter.IPAddress) Then
For i = 0 To UBound(objAdapter.IPAddress)
WScript.Echo "Addresse IP : " & objAdapter.IPAddress(i)
Next
End If
If Not IsNull(objAdapter.IPSubnet) Then
For i = 0 To UBound(objAdapter.IPSubnet)
WScript.Echo "Masque: " & objAdapter.IPSubnet(i)
Next
End If
If Not IsNull(objAdapter.DefaultIPGateway) Then
For i = 0 To UBound(objAdapter.DefaultIPGateway)
WScript.Echo "Passerelle: " & _
objAdapter.DefaultIPGateway(i)
Next
End If
WScript.Echo "Domaine DNS: " & objAdapter.DNSDomain
If Not IsNull(objAdapter.DNSDomainSuffixSearchOrder) Then
For i = 0 To UBound(objAdapter.DNSDomainSuffixSearchOrder)
WScript.Echo "DNS suffix search list: " & _
objAdapter.DNSDomainSuffixSearchOrder(i)
Next
End If
WScript.Echo "Poste en DHCP?: " & objAdapter.DHCPEnabled
WScript.Echo "Serveur DHCP: " & objAdapter.DHCPServer
If Not IsNull(objAdapter.DHCPLeaseObtained) Then
utcLeaseObtained = objAdapter.DHCPLeaseObtained
strLeaseObtained = WMIDateStringToDate(utcLeaseObtained)
Else
strLeaseObtained = ""
End If
WScript.Echo "Date du bail DHCP: " & strLeaseObtained
If Not IsNull(objAdapter.DHCPLeaseExpires) Then
utcLeaseExpires = objAdapter.DHCPLeaseExpires
strLeaseExpires = WMIDateStringToDate(utcLeaseExpires)
Else
strLeaseExpires = ""
End If
WScript.Echo "Expiration du bail DHCP: " & strLeaseExpires
WScript.Echo "Serveur WINS: " & objAdapter.WINSPrimaryServer
n = n + 1
Next
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

Laisser un commentaire

Cliquez ici pour révoquer votre décision.