begin process at 2008 05 17 04:24:37
1 173 904 membres
36 nouveaux aujourd'hui
13 973 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

ACTIVE DIRECTORY : LISTE LES PC DU RÉSEAU


Information sur la source

Description

Ce script tout simple se connecte à l'AD, liste les pc du réseau et écrit en sortie un fichier txt que vous pouvez importer dans toute autre application.

Bien que très simple et peut-être désuet comparé à du VB.NET, il reste toutefois très pratique et rapide.

Source

  • Dim args, oWinNT, oDomain
  • Dim Name
  • Set Shell = WScript.CreateObject("WScript.Shell")
  • domain="votre_domaine"
  • set oWinNT=GetObject("WinNT://" & domain)
  • Const ForReading = 1, ForWriting = 2
  • Set WshShell = WScript.CreateObject("WScript.Shell")
  • Dim fso, f
  • Set fso = CreateObject("Scripting.FileSystemObject")
  • objOutFile = "C:\temp\ADListPC.txt"
  • Set f = fso.OpenTextFile(objOutFile, ForWriting,true)
  • for each oDomain in oWinNT
  • if lcase(oDomain.class)="computer" then
  • Name = oDomain.name
  • if lcase(Mid(Name, 1,3))="lap" or lcase(Mid(Name, 1,3))="pos" then
  • f.writeline(Name)
  • end if
  • end if
  • next
  • '--------------------------------------------------------------------
  • ' Sous programme de test du moteur
  • ' Vu les sorties générées, c'est CSCRIPT (et non pas WSCRIPT)
  • ' qui doit être utilisé
  • Sub TestHost
  • dim rep
  • SW_SHOWNORMAL=1
  • strFullName =lcase(WScript.FullName)
  • strappli=lcase(Wscript.ScriptFullName)
  • i=InStr(1,strFullName,".exe",1)
  • j=InStrRev(strFullName,"\",i,1)
  • strCommand=Mid(strFullName,j+1,i-j-1)
  • if strCommand<>"cscript" then
  • rep=MsgBox("Ce script doit être lancé avec CSCRIPT" & VBCRLF & _
  • "Cela peut être rendu permanent avec la commande" & VBCRLF & _
  • "cscript //H:CScript //S /Nologo" & VBCRLF & _
  • "Voulez-vous que ce soit fait automatiquement?", _
  • vbYesNo + vbQuestion,strappli)
  • if rep=vbYes then
  • nomcmd="setscript.bat"
  • Set ficcmd = fso.CreateTextFile(nomcmd)
  • ficcmd.writeline "@echo off"
  • ficcmd.writeline "cscript //H:CScript //S /Nologo"
  • ficcmd.writeline "pause"
  • ficcmd.writeline chr(34) & strappli & chr(34)
  • ficcmd.writeline "pause"
  • ficcmd.close
  • shell.Run nomcmd, SW_SHOWNORMAL,true
  • end if
  • WScript.Quit
  • end if
  • end sub
  • '--------------------------------------------------------------------
Dim args, oWinNT, oDomain
Dim Name
Set Shell = WScript.CreateObject("WScript.Shell")
domain="votre_domaine"
set oWinNT=GetObject("WinNT://" & domain)

Const ForReading = 1, ForWriting = 2
  Set WshShell = WScript.CreateObject("WScript.Shell")
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
	objOutFile = "C:\temp\ADListPC.txt"
   	Set f = fso.OpenTextFile(objOutFile, ForWriting,true)
	for each oDomain in oWinNT
		if  lcase(oDomain.class)="computer" then
			Name = oDomain.name
			if lcase(Mid(Name, 1,3))="lap" or lcase(Mid(Name, 1,3))="pos" then
				f.writeline(Name)
			end if
		end if
	next

'--------------------------------------------------------------------
' Sous programme de test du moteur
' Vu les sorties générées, c'est CSCRIPT (et non pas WSCRIPT)
' qui doit être utilisé
Sub TestHost
dim rep
SW_SHOWNORMAL=1 
strFullName =lcase(WScript.FullName)
strappli=lcase(Wscript.ScriptFullName)
i=InStr(1,strFullName,".exe",1)
j=InStrRev(strFullName,"\",i,1)
strCommand=Mid(strFullName,j+1,i-j-1)
if strCommand<>"cscript" then
	rep=MsgBox("Ce script doit être lancé avec CSCRIPT" & VBCRLF & _ 
               "Cela peut être rendu permanent avec la commande" & VBCRLF & _
			   "cscript //H:CScript //S /Nologo" & VBCRLF & _
			   "Voulez-vous que ce soit fait automatiquement?", _
			   vbYesNo + vbQuestion,strappli)
	if rep=vbYes  then 
		nomcmd="setscript.bat"
		Set ficcmd = fso.CreateTextFile(nomcmd)
		ficcmd.writeline "@echo off"
		ficcmd.writeline "cscript //H:CScript //S /Nologo"
		ficcmd.writeline "pause"
		ficcmd.writeline chr(34) & strappli & chr(34) 
		ficcmd.writeline "pause"
		ficcmd.close
		shell.Run nomcmd, SW_SHOWNORMAL,true
		end if
    WScript.Quit
	end if
end sub
'--------------------------------------------------------------------
Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip

    Aucun commentaire pour le moment.

Ajouter un commentaire

Appels d'offres

Pub



CalendriCode

Mai 2008
LMMJVSD
   1234
567891011
12131415161718
19202122232425
262728293031 

Téléchargements

Logiciels à télécharger sur le même thème :

Boutique

Boutique de goodies CodeS-SourceS