Hitch16
Messages postés78Date d'inscriptionvendredi 4 février 2005StatutMembreDernière intervention 6 octobre 2008
-
31 oct. 2007 à 14:46
Hitch16
Messages postés78Date d'inscriptionvendredi 4 février 2005StatutMembreDernière intervention 6 octobre 2008
-
6 nov. 2007 à 12:05
Salut,
j'ai trouvé sur l'excellent site http://cwashington.netreach.net/ , un script permettant de remonter l'inventaire matériel des machines distantes sur le réseau. (j'ai juste "francisé" le passage en Excel...)
Je suis Administrateur de Domaine, sous AD avec un DC en 2k Server, les machines sont sous w2k (SP3 et SP4) et XP (SP1 et SP2), donc un parc parfaitement homogène...
J'arrive bien à remonter les infos de certaines machines mais pas sur d'autres... (SP et Services activés à l'identique).
Quelqu'un aurait une solution ??
Merci d'avance.
'******************
'Date: 12/21/2001
'Title: sms.vbs
'Use: Create hardware inventory and dumps info to Excel Spreadsheet.
'Comment: Must have ADSI and WMI installed on PC running script.
' Must have Admin rights on machines you connect to.
'******************
set fso = CreateObject("Scripting.FileSystemObject")
set f = fso.OpenTextFile(inputFile, ForReading, True)
set fsox = CreateObject("Scripting.FileSystemObject")
set fx = fsox.OpenTextFile(outputFile, ForWriting, True)
computerIndex = 1
'******************
'**[ FUNCTIONS ]***************
Function Ask(strAction)
intButton = MsgBox(strAction, vbQuestion + vbYesNo, TITLE) Ask intButton vbNo
End Function
'**[ MAIN SCRIPT ]*************
If Ask("Would you like to start inventory run") Then
Wscript.Quit
Else
strStart = "Inventory run started: " & Date & " at " & time
End If
Call BuildXLS()
Call Connect()
Call Footer()
objXL.ActiveWorkbook.SaveAs "c:\sms.xls"
MsgBox "Inventory run is complete!", vbInformation + vbOKOnly, TITLE
'******************
'**[ SUB ROUTINES ]************
'*** Subroutine Connect ***
Sub Connect()
Do While f.AtEndOfLine <> True
strPC = f.ReadLine
Call Error()
On Error Resume Next
strCompName = UCase(strPC)
set BIOSSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strPC & "/root/cimv2").ExecQuery("select SerialNumber from Win32_BIOS")
for each BIOS in BIOSSet
strSN = BIOS.SerialNumber
Next
set MemorySet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strPC & "/root/cimv2").ExecQuery("select TotalPhysicalMemory, TotalVirtualMemory, TotalPageFileSpace from Win32_LogicalMemoryConfiguration")
for each Memory in MemorySet
strRAM = FormatNumber(Memory.TotalPhysicalMemory/1024,1) & " Mbytes"
strVir = FormatNumber(Memory.TotalVirtualMemory/1024,1) & " Mbytes"
strPage = FormatNumber(Memory.TotalPageFileSpace/1024,1) & " Mbytes"
Next
set OSSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strPC & "/root/cimv2").ExecQuery("select Caption, CSDVersion, SerialNumber from Win32_OperatingSystem")
for each OS in OSSet
strOS = OS.Caption
strSP = OS.CSDVersion
strProdID = OS.SerialNumber
Next
set IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strPC & "/root/cimv2").ExecQuery("select ServiceName, IPAddress, IPSubnet, DefaultIPGateway, MACAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
Count = 0
for each IPConfig in IPConfigSet
Count = Count + 1
Next
ReDim sName(Count - 1)
ReDim sIP(Count - 1)
ReDim sMask(Count - 1)
ReDim sGate(Count - 1)
ReDim sMAC(Count - 1)
Count = 0
for each IPConfig in IPConfigSet
sName(Count) = IPConfig.ServiceName(0)
strNIC = sName(Count)
sIP(Count) = IPConfig.IPAddress(0)
strIP = sIP(Count)
sMask(Count) = IPConfig.IPSubnet(0)
strMask = sMask(Count)
sGate(Count) = IPConfig.DefaultIPGateway(0)
strGate = sGate(Count)
sMAC(Count) = IPConfig.MACAddress(0)
strMAC = sMAC(Count)
Count = Count + 1
Next
set ProSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strPC & "/root/cimv2").ExecQuery("select Name, MaxClockSpeed from Win32_Processor")
for each Pro in ProSet
strProc = Pro.Name
strSpeed = Pro.MaxClockSpeed
Next
'*** Set Cell Format for Column Titles ***
objXL.Range("A1:T1").Select
objXL.Selection.Font.Bold = True
objXL.Selection.Interior.ColorIndex = 9
objXL.Selection.Interior.Pattern = 1 'xlSolid
objXL.Selection.Font.ColorIndex = 2
objXL.Selection.WrapText = True
objXL.Columns("A:T").Select
objXL.Selection.HorizontalAlignment = 3 'xlCenter
'*** Set Column Titles ***
Call AddLineToXLS("Nom du pc","Numéro de serie","ID du lecteur","Type de partition","Taille du disque","Espace libre","Espace utilisé","Mémoire physique","Mémoire virtuelle","Fichier d'échange","Système d'exploitation","Service Pack","ID du produit","Carte réseau","Addresse IP","Masque de sous-réseau","Passerelle par défaut","Adresse MAC","Processeur","Vitesse")
Sub Disk_C()
set DiskSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strPC & "/root/cimv2").ExecQuery("select DeviceID, FileSystem, Size, FreeSpace from Win32_LogicalDisk where DeviceID = 'C:' and DriveType = '3'")
ReDim strDisk(RowNum,4)
for each Disk in DiskSet
strDisk(RowNum,DEV_ID)= Disk.DeviceID
strDisk(RowNum,FSYS)= Disk.FileSystem
strDisk(RowNum,DSIZE)= FormatNumber(Disk.Size/2^30,1) & " Gbytes"
strDisk(RowNum,FSPACE)= FormatNumber(Disk.FreeSpace/2^30,1) & " Gbytes"
strDisk(RowNum,USPACE)= FormatNumber((Disk.Size-Disk.FreeSpace)/2^30,1) & " Gbytes"
Call AddLineToXLS(strCompName, strSN, strDisk(RowNum,DEV_ID), strDisk(RowNum,FSYS), strDisk(RowNum,DSIZE), strDisk(RowNum,FSPACE), strDisk(RowNum,USPACE), strRAM, strVir, strPage, strOS, strSP, strProdID, strNIC, strIP, strMask, strGate, strMAC, strProc, strSpeed)
Next
End Sub
'*** Subroutine to parse D: Partition ***
Sub Disk_D()
set DiskSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strPC & "/root/cimv2").ExecQuery("select DeviceID, FileSystem, Size, FreeSpace from Win32_LogicalDisk where DeviceID = 'D:' and DriveType = '3'")
On Error Resume Next
ReDim strDisk(RowNum,4)
for each Disk in DiskSet
strDisk(RowNum,DEV_ID)= Disk.DeviceID
strDisk(RowNum,FSYS)= Disk.FileSystem
strDisk(RowNum,DSIZE)= FormatNumber(Disk.Size/2^30,1) & " Gbytes"
strDisk(RowNum,FSPACE)= FormatNumber(Disk.FreeSpace/2^30,1) & " Gbytes"
strDisk(RowNum,USPACE)= FormatNumber((Disk.Size-Disk.FreeSpace)/2^30,1) & " Gbytes"
If IsNull(strDisk(RowNum,FSYS)) Then
Exit Sub
End If
Call AddLineToDisk(strDisk(RowNum,DEV_ID), strDisk(RowNum,FSYS), strDisk(RowNum,DSIZE), strDisk(RowNum,FSPACE), strDisk(RowNum,USPACE))
Next
End Sub
Sub Disk_E()
set DiskSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strPC & "/root/cimv2").ExecQuery("select DeviceID, FileSystem, Size, FreeSpace from Win32_LogicalDisk where DeviceID = 'E:' and DriveType = '3'")
On Error Resume Next
ReDim strDisk(RowNum,4)
for each Disk in DiskSet
strDisk(RowNum,DEV_ID)= Disk.DeviceID
strDisk(RowNum,FSYS)= Disk.FileSystem
strDisk(RowNum,DSIZE)= FormatNumber(Disk.Size/2^30,1) & " Gbytes"
strDisk(RowNum,FSPACE)= FormatNumber(Disk.FreeSpace/2^30,1) & " Gbytes"
strDisk(RowNum,USPACE)= FormatNumber((Disk.Size-Disk.FreeSpace)/2^30,1) & " Gbytes"
If IsNull(strDisk(RowNum,FSYS)) Then
Exit Sub
End If
Call AddLineToDisk(strDisk(RowNum,DEV_ID), strDisk(RowNum,FSYS), strDisk(RowNum,DSIZE), strDisk(RowNum,FSPACE), strDisk(RowNum,USPACE))
Next
End Sub
'*** Delete file if exists ***
Sub KillFile()
Set objKill = CreateObject("Scripting.FileSystemObject")
If (objKill.FileExists("c:\sms.xls")) Then
objKill.DeleteFile("c:\sms.xls")
End If
If (objKill.FileExists("c:\PC_Inv_NA.txt")) Then
objKill.DeleteFile("c:\PC_Inv_NA.txt")
End If
Set objKill = Nothing
End Sub
'*** Sub to add footer when speadsheet is complete ***
Sub Footer()
strFooter1 = "Reliant Resources Inc., DTS"
strFooter2 = "Script provided for creating PC Hardware Inventory"
strComplete = "Inventory run completed: " & Date & " at " & time
intRow = intRow + 5
'** Set Cell Format for Row
objXL.Cells(intRow, 1).Select
objXL.Selection.Font.ColorIndex = 1
objXL.Selection.Font.Size = 8
objXL.Selection.Font.Bold = False
objXL.Selection.HorizontalAlignment = 2 'xlLeft
objXL.Cells(intRow, 1).Value = strFooter1
intRow = intRow + 1
'** Set Cell Format for Row
objXL.Cells(intRow, 1).Select
objXL.Selection.Font.ColorIndex = 1
objXL.Selection.Font.Size = 8
objXL.Selection.Font.Bold = False
objXL.Selection.HorizontalAlignment = 2 'xlLeft
objXL.Cells(intRow, 1).Value = strFooter2
intRow = intRow + 1
'** Set Cell Format for Row
objXL.Cells(intRow, 1).Select
objXL.Selection.Font.ColorIndex = 1
objXL.Selection.Font.Size = 8
objXL.Selection.Font.Bold = False
objXL.Selection.HorizontalAlignment = 2 'xlLeft
objXL.Cells(intRow, 1).Value = strStart
intRow = intRow + 1
'** Set Cell Format for Row
objXL.Cells(intRow, 1).Select
objXL.Selection.Font.ColorIndex = 1
objXL.Selection.Font.Size = 8
objXL.Selection.Font.Bold = False
objXL.Selection.HorizontalAlignment = 2 'xlLeft
objXL.Cells(intRow, 1).Value = strComplete
intRow = intRow + 1
End Sub
'*** ErrorHandler ***
Sub Error()
On Error Resume Next
set CompSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strPC & "/root/cimv2").ExecQuery("select Name from Win32_ComputerSystem")
If Err Then
fx.WriteLine(strPC)
End If
computerIndex = computerIndex + 1
End Sub
Hitch16
Messages postés78Date d'inscriptionvendredi 4 février 2005StatutMembreDernière intervention 6 octobre 2008 31 oct. 2007 à 14:53
J'ai oublié de préciser qu'il fallait entrer l'inventaire du nom des machines dans le fichier "C:\PC_Inv.txt"
En sorite on a les machines qui n'ont pas pu être contactées dans "C:\PC_Inv_NA.txt" et le beau tableau Excel avec l'inventaire Hardware...
Kristof_Koder
Messages postés918Date d'inscriptionvendredi 3 août 2007StatutMembreDernière intervention27 octobre 200810 1 nov. 2007 à 15:50
"en tant qu'administrateur du domaine j'ai tous les droits" < Faux ! Tu peux très bien ne pas avoir accès à certaines partie de ton réseau. Pour exemple, sur le LAN de mon boulot, il y a un PC et deux partages réseau auxquels moi, administrateur, je n'ai pas du tout accès : Ils hébergent des documents de notre direction.
Vous n’avez pas trouvé la réponse que vous recherchez ?