|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Bonjour,
Je ne sais pas si je poste dans le bon forum... Alors voila, je travail actuellement dans un AD, et je dois faire une liste des clients (uniquement XP) sur lesquels un certain service est installé. Comme ca ca a l'air plutot simple, mais en fait je ne vois pas trop comment m'y prendre... A ma connaissance il n'y a pas d'outils tout fait qui sache faire cela, ni par stratégie de groupe, je planche actuellement sur un scripts VBS mais c'est vraiment pas évident n'ayant pas été formé dessus, tout ne viens pas naturellement... J'arrive à le faire en locale et de facon pas vraiment optimisé, ce qui me laisse craindre le plantage vu la taille du réseau... Bref si quelqu'un à une idée sur comment je pourrais m'y prendre (pas de MOM désolé ) ou a déjà des scripts dans le style, je suis preneur.D'avance merci ! |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Bonjour ,
Votre meilleure solution pour ces scenarion eSt d'utilisez SMS ( Software management services) http://www.microsoft.com/smserver/default.mspx vous pouvez telecharger la version d'evaluation et vous allez vois ce que vous pouvez faite avec . Omar "Alexfoo" <Alexfoo@discussions.microsoft.com> wrote in message news:A71026FD-8F9F-4CE5-9E8B-B681862439AE@microsoft.com... > Bonjour, > > Je ne sais pas si je poste dans le bon forum... Alors voila, je travail > actuellement dans un AD, et je dois faire une liste des clients > (uniquement > XP) sur lesquels un certain service est installé. Comme ca ca a l'air > plutot > simple, mais en fait je ne vois pas trop comment m'y prendre... > > A ma connaissance il n'y a pas d'outils tout fait qui sache faire cela, ni > par stratégie de groupe, je planche actuellement sur un scripts VBS mais > c'est vraiment pas évident n'ayant pas été formé dessus, tout ne viens pas > naturellement... J'arrive à le faire en locale et de facon pas vraiment > optimisé, ce qui me laisse craindre le plantage vu la taille du réseau... > > Bref si quelqu'un à une idée sur comment je pourrais m'y prendre (pas de > MOM > désolé ) ou a déjà des scripts dans le style, je suis preneur.> > D'avance merci ! |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Bonjour Alex,
je penses aussi qu'un script partant sur du WMI serait la meilleure solution. Je peux jeter un coup d'oeil pour essayer de t'aider mais sincèrement, la meilleure méthode serait de poser la question sur microsoft.public.fr.scipting. Une autre bonne chose serait pour toi de jeter un coup d'oeil au scriptcenter, notamment ici http://www.microsoft.com/technet/scr....mspx?mfr=true ou là http://www.microsoft.com/technet/scr.../cscos024.mspx Évidemment, te plonger dans l'univers du scripting serait LA solution, maintenant si urgence il y a... Cordialement, -- Jonathan BISMUTH MVP Windows Server - Directory Services MCSE 2000/ADSI-AutoIT Scripter Transcript (ID: 691839, code: MCSE2000) www.portail-mcse.net "Alexfoo" <Alexfoo@discussions.microsoft.com> a écrit dans le message de news: A71026FD-8F9F-4CE5-9E8B-B681862439AE@microsoft.com... > Bonjour, > > Je ne sais pas si je poste dans le bon forum... Alors voila, je travail > actuellement dans un AD, et je dois faire une liste des clients > (uniquement > XP) sur lesquels un certain service est installé. Comme ca ca a l'air > plutot > simple, mais en fait je ne vois pas trop comment m'y prendre... > > A ma connaissance il n'y a pas d'outils tout fait qui sache faire cela, ni > par stratégie de groupe, je planche actuellement sur un scripts VBS mais > c'est vraiment pas évident n'ayant pas été formé dessus, tout ne viens pas > naturellement... J'arrive à le faire en locale et de facon pas vraiment > optimisé, ce qui me laisse craindre le plantage vu la taille du réseau... > > Bref si quelqu'un à une idée sur comment je pourrais m'y prendre (pas de > MOM > désolé ) ou a déjà des scripts dans le style, je suis preneur.> > D'avance merci ! |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Merci Omar, j'avais déjà pensé à SMS, malheureusement il n'est pas possible
d'ajouter de nouveaux agents sur les postes... y'en a déjà pour l'antivirus, le déploiement et le firewall... trop lourd à gérer... Pour ce qui est des scripts biensûr j'ai déjà regardé le "scripcenter" et "scriptomatic", le probleme est que les scripts proposés ont TOUS la meme structure , à savoir un "select *", suivit d'un "pour chaque entrée de chaque occurence renvoyé par la requete", affiché ceci... Hors la syntaxe WMI & VBS est casse c*** pour faire des choses toutes simples en langages classiques (VB6, .NET, etc...) c'est la croix et la bannière j'ai du mal... Bon enfin apparement il va falloir que je persiste dans cette voix, merci quand meme ! "Jonathan BISMUTH" a écrit : > Bonjour Alex, > > je penses aussi qu'un script partant sur du WMI serait la meilleure > solution. > Je peux jeter un coup d'oeil pour essayer de t'aider mais sincèrement, la > meilleure méthode serait de poser la question sur > microsoft.public.fr.scipting. > > Une autre bonne chose serait pour toi de jeter un coup d'oeil au > scriptcenter, notamment ici > http://www.microsoft.com/technet/scr....mspx?mfr=true > ou là > http://www.microsoft.com/technet/scr.../cscos024.mspx > > Évidemment, te plonger dans l'univers du scripting serait LA solution, > maintenant si urgence il y a... > > Cordialement, > -- > Jonathan BISMUTH > MVP Windows Server - Directory Services > MCSE 2000/ADSI-AutoIT Scripter > Transcript (ID: 691839, code: MCSE2000) > www.portail-mcse.net > > "Alexfoo" <Alexfoo@discussions.microsoft.com> a écrit dans le message de > news: A71026FD-8F9F-4CE5-9E8B-B681862439AE@microsoft.com... > > Bonjour, > > > > Je ne sais pas si je poste dans le bon forum... Alors voila, je travail > > actuellement dans un AD, et je dois faire une liste des clients > > (uniquement > > XP) sur lesquels un certain service est installé. Comme ca ca a l'air > > plutot > > simple, mais en fait je ne vois pas trop comment m'y prendre... > > > > A ma connaissance il n'y a pas d'outils tout fait qui sache faire cela, ni > > par stratégie de groupe, je planche actuellement sur un scripts VBS mais > > c'est vraiment pas évident n'ayant pas été formé dessus, tout ne viens pas > > naturellement... J'arrive à le faire en locale et de facon pas vraiment > > optimisé, ce qui me laisse craindre le plantage vu la taille du réseau... > > > > Bref si quelqu'un à une idée sur comment je pourrais m'y prendre (pas de > > MOM > > désolé ) ou a déjà des scripts dans le style, je suis preneur.> > > > D'avance merci ! > > > |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
"Alexfoo" <Alexfoo@discussions.microsoft.com> wrote in message
news:645011DD-89D2-4EE2-88FC-C9A5DC53D8B0@microsoft.com... > Merci Omar, j'avais déjà pensé à SMS, malheureusement il n'est pas > possible > d'ajouter de nouveaux agents sur les postes... y'en a déjà pour > l'antivirus, > le déploiement et le firewall... trop lourd à gérer... > > Pour ce qui est des scripts biensûr j'ai déjà regardé le "scripcenter" et > "scriptomatic", le probleme est que les scripts proposés ont TOUS la meme > structure , à savoir un "select *", suivit d'un "pour chaque entrée de > chaque > occurence renvoyé par la requete", affiché ceci... > > Hors la syntaxe WMI & VBS est casse c*** pour faire des choses toutes > simples en langages classiques (VB6, .NET, etc...) c'est la croix et la > bannière j'ai du mal... Si tu as une expérience même petite en programmation "classique" et que tu es encore novice en matière de scripting pour Windows, je te conseille de te mettre plutôt à Windows PowerShell, environnement sur lequel Microsoft concentre ses efforts pour le scripting dans les années à venir. Avec PowerShell, la requête dont tu as besoin ne devrait pas être plus longue que deux ou trois commandes: une pour récupérer tous les ordinateurs de l'AD (requête ADSI), une pour interroger chaque ordinateur récupéré sur la présence ou non du service en question (requête WMI), et éventuellement une commande pour formater le résultat. Et puis allez, ajoutons une quatrième commande pour écrire le résultat dans un fichier. Pour installer PowerShell: http://www.microsoft.com/downloads/r...DisplayLang=fr. Tu n'as besoin d'installer PowerShell que sur le poste à partir duquel tu lanceras ton script. Il suffit que ce poste ait accès à l'AD et aux ordinateurs à interroger, et que le compte qui lance le script ait les autorisations nécessaires. Si tu n'y arrives pas, repose la question sur le forum de scripting - comme suggéré par Jonathan, il est plus adapté pour ce genre de problématique. Jacques |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
'================================================= =========================
' ' ' NAME: <ListComputerUsingParticularService.vbs> ' ' AUTHOR: Ed Wilson , MS ' DATE : 8/14/2006 ' ' COMMENT: <Reports using win32_Service class> '1. will list all services using a particular startup account. '================================================= ========================= Option Explicit 'On Error Resume Next dim strComputer dim wmiNS dim wmiQuery dim objWMIService Dim objLocator dim colItems dim objItem Dim strUsr, strPWD, strLocl, strAuth, iFLag 'connect server parameters Dim colNamedArguments 'WshNamed object Dim strName 'service Name subCheckCscript 'check to see if running in cscript Set colNamedArguments = WScript.Arguments.Named strComputer = colNamedArguments("c") strName = colNamedArguments("s") 'the service name subCheckArguments wmiNS = "\root\cimv2" wmiQuery = "Select name,state from win32_Service where Name = '" & strName & "'" strUsr = colNamedArguments("u") '""'Blank for current security. Domain\Username strPWD = colNamedArguments("p") '""'Blank for current security. strLocl = "" '"MS_409" 'US English. Can leave blank for current language strAuth = ""'if specify domain in strUsr this must be blank iFlag = "0" 'only two values allowed here: 0 (wait for connection) 128 (wait max two min) Set objLocator = CreateObject("WbemScripting.SWbemLocator") Set objWMIService = objLocator.ConnectServer(strComputer, _ wmiNS, strUsr, strPWD, strLocl, strAuth, iFLag) Select Case strName Case "a" wmiQuery = "Select name,state from win32_Service" Case "r" wmiQuery = "Select name,state from win32_Service where state = 'running'" Case "s" wmiQuery = "Select name,state from win32_Service where state = 'stopped'" Case Else wmiQuery = "Select name,state from win32_Service where Name = '" & strName & "'" End Select Set colItems = objWMIService.ExecQuery(wmiQuery) For Each objItem in colItems If objItem.state = "Running" Then Wscript.Echo "Service: " & objItem.name & " is running on " & strComputer Else WScript.Echo "Service: " & objItem.name & " is not running on " & strComputer End If Next ' *** subs are below *** Sub subCheckCscript If UCase(Right(Wscript.FullName, 11)) = "WSCRIPT.EXE" Then Wscript.Echo "This script must be run under CScript" WScript.Quit End If end Sub Sub subCheckArguments If colNamedArguments.Count < 6 Then If colNamedArguments.Exists("?") Then WScript.Echo "Uses win32_Service to identify a running service" _ & VbCrLf & "This script can take arguments. It will identify a computer running a service"_ & VbCrLf & "If you supply the script with a list of computer names, then it will check each" _ & VbCrLf & "computer to see if it is running a particular service. This is useful from both" _ & VbCrLf & "a security and an administrative perspective. This script can run local or remote" _ & VbCrLf & "The service name to query is the registered name NOT the friendly name. As an " _ & VbCrLf & "example: the server service is registered as lanmanserver" _ & VbCrLf & "Alternate credentials can ONLY be supplied for remote connections" _ & VbCrLf & "Try this: cscript " & WScript.ScriptName & " [/s:serviceName, a(all),r(running),s(stopped)] [/c:computername]" _ & " [/u:domainName\UserName] [/p:password]" _ & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:alerter" _ & VbCrLf & vbTab & "Displays the status of the alerter service on local machine." _ & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:alerter /c:london" _ & VbCrLf & vbTab & "/u:nwtraders\myUser /p:myPassword" _ & VbCrLf & vbTab & "Displays the status of the alterter service on a remote machine" _ & VbCrLf & vbTab & "called London. Connects using myUser account from NWTraders domain." _ & VbCrLf & vbTab & "the password supplied for the connection is myPassword" _ & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:r" _ & VbCrLf & vbTab & "Displays list of all running services on local machine." _ & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:s" _ & VbCrLf & vbTab & "Displays list of all stopped services on local machine." WScript.Quit End If If Not colNamedArguments.Exists("c") Then WScript.Echo "Executing on Local Machine only" strComputer = "localHost" End If If Not colNamedArguments.Exists("u") Then WScript.Echo "Executing using current user name" strUsr = "" End If If Not colNamedArguments.Exists("p") Then WScript.Echo "Executing using current user password" strPWD = "" End If If Not colNamedArguments.Exists("s") Then WScript.Echo "Using Defaults: status of all services" WScript.Echo "To see try this: cscript ",WScript.ScriptName, " /?" strName = "a" End If End If If colNamedArguments.Count = 0 Then Exit Sub End If End Sub -- Cordialement, Mathieu CHATEAU http://lordoftheping.blogspot.com "Alexfoo" <Alexfoo@discussions.microsoft.com> wrote in message news:A71026FD-8F9F-4CE5-9E8B-B681862439AE@microsoft.com... > Bonjour, > > Je ne sais pas si je poste dans le bon forum... Alors voila, je travail > actuellement dans un AD, et je dois faire une liste des clients > (uniquement > XP) sur lesquels un certain service est installé. Comme ca ca a l'air > plutot > simple, mais en fait je ne vois pas trop comment m'y prendre... > > A ma connaissance il n'y a pas d'outils tout fait qui sache faire cela, ni > par stratégie de groupe, je planche actuellement sur un scripts VBS mais > c'est vraiment pas évident n'ayant pas été formé dessus, tout ne viens pas > naturellement... J'arrive à le faire en locale et de facon pas vraiment > optimisé, ce qui me laisse craindre le plantage vu la taille du réseau... > > Bref si quelqu'un à une idée sur comment je pourrais m'y prendre (pas de > MOM > désolé ) ou a déjà des scripts dans le style, je suis preneur.> > D'avance merci ! |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
Merci pour votre aide, dès que j'ai le temps je me documente sur Powershell
et je me plonge sur ce script qui à l'air tres complet. Je vous tiens au courant de mes avancés, encore une fois merci. "Mathieu CHATEAU" a écrit : > '================================================= ========================= > ' > ' > ' NAME: <ListComputerUsingParticularService.vbs> > ' > ' AUTHOR: Ed Wilson , MS > ' DATE : 8/14/2006 > ' > ' COMMENT: <Reports using win32_Service class> > '1. will list all services using a particular startup account. > '================================================= ========================= > > Option Explicit > 'On Error Resume Next > dim strComputer > dim wmiNS > dim wmiQuery > dim objWMIService > Dim objLocator > dim colItems > dim objItem > Dim strUsr, strPWD, strLocl, strAuth, iFLag 'connect server parameters > Dim colNamedArguments 'WshNamed object > Dim strName 'service Name > > subCheckCscript 'check to see if running in cscript > Set colNamedArguments = WScript.Arguments.Named > strComputer = colNamedArguments("c") > strName = colNamedArguments("s") 'the service name > subCheckArguments > > wmiNS = "\root\cimv2" > > wmiQuery = "Select name,state from win32_Service where Name = '" & strName & > "'" > strUsr = colNamedArguments("u") '""'Blank for current security. > Domain\Username > strPWD = colNamedArguments("p") '""'Blank for current security. > strLocl = "" '"MS_409" 'US English. Can leave blank for current language > strAuth = ""'if specify domain in strUsr this must be blank > iFlag = "0" 'only two values allowed here: 0 (wait for connection) 128 (wait > max two min) > > Set objLocator = CreateObject("WbemScripting.SWbemLocator") > Set objWMIService = objLocator.ConnectServer(strComputer, _ > wmiNS, strUsr, strPWD, strLocl, strAuth, iFLag) > > Select Case strName > Case "a" > wmiQuery = "Select name,state from win32_Service" > Case "r" > wmiQuery = "Select name,state from win32_Service where state = 'running'" > Case "s" > wmiQuery = "Select name,state from win32_Service where state = 'stopped'" > Case Else > wmiQuery = "Select name,state from win32_Service where Name = '" & strName & > "'" > End Select > > Set colItems = objWMIService.ExecQuery(wmiQuery) > For Each objItem in colItems > If objItem.state = "Running" Then > Wscript.Echo "Service: " & objItem.name & " is running on " & > strComputer > Else > WScript.Echo "Service: " & objItem.name & " is not running on " & > strComputer > End If > Next > > > ' *** subs are below *** > Sub subCheckCscript > If UCase(Right(Wscript.FullName, 11)) = "WSCRIPT.EXE" Then > Wscript.Echo "This script must be run under CScript" > WScript.Quit > End If > end Sub > > Sub subCheckArguments > > If colNamedArguments.Count < 6 Then > If colNamedArguments.Exists("?") Then > WScript.Echo "Uses win32_Service to identify a running service" _ > & VbCrLf & "This script can take arguments. It will identify a computer > running a service"_ > & VbCrLf & "If you supply the script with a list of computer names, then it > will check each" _ > & VbCrLf & "computer to see if it is running a particular service. This is > useful from both" _ > & VbCrLf & "a security and an administrative perspective. This script can > run local or remote" _ > & VbCrLf & "The service name to query is the registered name NOT the > friendly name. As an " _ > & VbCrLf & "example: the server service is registered as lanmanserver" _ > & VbCrLf & "Alternate credentials can ONLY be supplied for remote > connections" _ > & VbCrLf & "Try this: cscript " & WScript.ScriptName & " [/s:serviceName, > a(all),r(running),s(stopped)] [/c:computername]" _ > & " [/u:domainName\UserName] [/p:password]" _ > & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:alerter" > _ > & VbCrLf & vbTab & "Displays the status of the alerter service on local > machine." _ > & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:alerter > /c:london" _ > & VbCrLf & vbTab & "/u:nwtraders\myUser /p:myPassword" _ > & VbCrLf & vbTab & "Displays the status of the alterter service on a remote > machine" _ > & VbCrLf & vbTab & "called London. Connects using myUser account from > NWTraders domain." _ > & VbCrLf & vbTab & "the password supplied for the connection is myPassword" > _ > & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:r" _ > & VbCrLf & vbTab & "Displays list of all running services on local > machine." _ > & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:s" _ > & VbCrLf & vbTab & "Displays list of all stopped services on local > machine." > WScript.Quit > End If > If Not colNamedArguments.Exists("c") Then > WScript.Echo "Executing on Local Machine only" > strComputer = "localHost" > End If > If Not colNamedArguments.Exists("u") Then > WScript.Echo "Executing using current user name" > strUsr = "" > End If > If Not colNamedArguments.Exists("p") Then > WScript.Echo "Executing using current user password" > strPWD = "" > End If > If Not colNamedArguments.Exists("s") Then > WScript.Echo "Using Defaults: status of all services" > WScript.Echo "To see try this: cscript ",WScript.ScriptName, " /?" > strName = "a" > End If > End If > If colNamedArguments.Count = 0 Then > Exit Sub > End If > End Sub > > -- > Cordialement, > Mathieu CHATEAU > http://lordoftheping.blogspot.com > > > "Alexfoo" <Alexfoo@discussions.microsoft.com> wrote in message > news:A71026FD-8F9F-4CE5-9E8B-B681862439AE@microsoft.com... > > Bonjour, > > > > Je ne sais pas si je poste dans le bon forum... Alors voila, je travail > > actuellement dans un AD, et je dois faire une liste des clients > > (uniquement > > XP) sur lesquels un certain service est installé. Comme ca ca a l'air > > plutot > > simple, mais en fait je ne vois pas trop comment m'y prendre... > > > > A ma connaissance il n'y a pas d'outils tout fait qui sache faire cela, ni > > par stratégie de groupe, je planche actuellement sur un scripts VBS mais > > c'est vraiment pas évident n'ayant pas été formé dessus, tout ne viens pas > > naturellement... J'arrive à le faire en locale et de facon pas vraiment > > optimisé, ce qui me laisse craindre le plantage vu la taille du réseau... > > > > Bref si quelqu'un à une idée sur comment je pourrais m'y prendre (pas de > > MOM > > désolé ) ou a déjà des scripts dans le style, je suis preneur.> > > > D'avance merci ! > > |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
ce script n'est pas en powershell mais bien en VBS
-- Cordialement, Mathieu CHATEAU http://lordoftheping.blogspot.com "Alexfoo" <Alexfoo@discussions.microsoft.com> wrote in message news:1AC140E2-308D-4325-A4A8-BDB623A97223@microsoft.com... > Merci pour votre aide, dès que j'ai le temps je me documente sur > Powershell > et je me plonge sur ce script qui à l'air tres complet. > > Je vous tiens au courant de mes avancés, encore une fois merci. > > "Mathieu CHATEAU" a écrit : > >> '================================================= ========================= >> ' >> ' >> ' NAME: <ListComputerUsingParticularService.vbs> >> ' >> ' AUTHOR: Ed Wilson , MS >> ' DATE : 8/14/2006 >> ' >> ' COMMENT: <Reports using win32_Service class> >> '1. will list all services using a particular startup account. >> '================================================= ========================= >> >> Option Explicit >> 'On Error Resume Next >> dim strComputer >> dim wmiNS >> dim wmiQuery >> dim objWMIService >> Dim objLocator >> dim colItems >> dim objItem >> Dim strUsr, strPWD, strLocl, strAuth, iFLag 'connect server parameters >> Dim colNamedArguments 'WshNamed object >> Dim strName 'service Name >> >> subCheckCscript 'check to see if running in cscript >> Set colNamedArguments = WScript.Arguments.Named >> strComputer = colNamedArguments("c") >> strName = colNamedArguments("s") 'the service name >> subCheckArguments >> >> wmiNS = "\root\cimv2" >> >> wmiQuery = "Select name,state from win32_Service where Name = '" & >> strName & >> "'" >> strUsr = colNamedArguments("u") '""'Blank for current security. >> Domain\Username >> strPWD = colNamedArguments("p") '""'Blank for current security. >> strLocl = "" '"MS_409" 'US English. Can leave blank for current language >> strAuth = ""'if specify domain in strUsr this must be blank >> iFlag = "0" 'only two values allowed here: 0 (wait for connection) 128 >> (wait >> max two min) >> >> Set objLocator = CreateObject("WbemScripting.SWbemLocator") >> Set objWMIService = objLocator.ConnectServer(strComputer, _ >> wmiNS, strUsr, strPWD, strLocl, strAuth, iFLag) >> >> Select Case strName >> Case "a" >> wmiQuery = "Select name,state from win32_Service" >> Case "r" >> wmiQuery = "Select name,state from win32_Service where state = 'running'" >> Case "s" >> wmiQuery = "Select name,state from win32_Service where state = 'stopped'" >> Case Else >> wmiQuery = "Select name,state from win32_Service where Name = '" & >> strName & >> "'" >> End Select >> >> Set colItems = objWMIService.ExecQuery(wmiQuery) >> For Each objItem in colItems >> If objItem.state = "Running" Then >> Wscript.Echo "Service: " & objItem.name & " is running on " & >> strComputer >> Else >> WScript.Echo "Service: " & objItem.name & " is not running on " & >> strComputer >> End If >> Next >> >> >> ' *** subs are below *** >> Sub subCheckCscript >> If UCase(Right(Wscript.FullName, 11)) = "WSCRIPT.EXE" Then >> Wscript.Echo "This script must be run under CScript" >> WScript.Quit >> End If >> end Sub >> >> Sub subCheckArguments >> >> If colNamedArguments.Count < 6 Then >> If colNamedArguments.Exists("?") Then >> WScript.Echo "Uses win32_Service to identify a running service" _ >> & VbCrLf & "This script can take arguments. It will identify a computer >> running a service"_ >> & VbCrLf & "If you supply the script with a list of computer names, then >> it >> will check each" _ >> & VbCrLf & "computer to see if it is running a particular service. This >> is >> useful from both" _ >> & VbCrLf & "a security and an administrative perspective. This script >> can >> run local or remote" _ >> & VbCrLf & "The service name to query is the registered name NOT the >> friendly name. As an " _ >> & VbCrLf & "example: the server service is registered as lanmanserver" _ >> & VbCrLf & "Alternate credentials can ONLY be supplied for remote >> connections" _ >> & VbCrLf & "Try this: cscript " & WScript.ScriptName & " >> [/s:serviceName, >> a(all),r(running),s(stopped)] [/c:computername]" _ >> & " [/u:domainName\UserName] [/p:password]" _ >> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " >> /s:alerter" >> _ >> & VbCrLf & vbTab & "Displays the status of the alerter service on local >> machine." _ >> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " >> /s:alerter >> /c:london" _ >> & VbCrLf & vbTab & "/u:nwtraders\myUser /p:myPassword" _ >> & VbCrLf & vbTab & "Displays the status of the alterter service on a >> remote >> machine" _ >> & VbCrLf & vbTab & "called London. Connects using myUser account from >> NWTraders domain." _ >> & VbCrLf & vbTab & "the password supplied for the connection is >> myPassword" >> _ >> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:r" _ >> & VbCrLf & vbTab & "Displays list of all running services on local >> machine." _ >> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:s" _ >> & VbCrLf & vbTab & "Displays list of all stopped services on local >> machine." >> WScript.Quit >> End If >> If Not colNamedArguments.Exists("c") Then >> WScript.Echo "Executing on Local Machine only" >> strComputer = "localHost" >> End If >> If Not colNamedArguments.Exists("u") Then >> WScript.Echo "Executing using current user name" >> strUsr = "" >> End If >> If Not colNamedArguments.Exists("p") Then >> WScript.Echo "Executing using current user password" >> strPWD = "" >> End If >> If Not colNamedArguments.Exists("s") Then >> WScript.Echo "Using Defaults: status of all services" >> WScript.Echo "To see try this: cscript ",WScript.ScriptName, " /?" >> strName = "a" >> End If >> End If >> If colNamedArguments.Count = 0 Then >> Exit Sub >> End If >> End Sub >> >> -- >> Cordialement, >> Mathieu CHATEAU >> http://lordoftheping.blogspot.com >> >> >> "Alexfoo" <Alexfoo@discussions.microsoft.com> wrote in message >> news:A71026FD-8F9F-4CE5-9E8B-B681862439AE@microsoft.com... >> > Bonjour, >> > >> > Je ne sais pas si je poste dans le bon forum... Alors voila, je travail >> > actuellement dans un AD, et je dois faire une liste des clients >> > (uniquement >> > XP) sur lesquels un certain service est installé. Comme ca ca a l'air >> > plutot >> > simple, mais en fait je ne vois pas trop comment m'y prendre... >> > >> > A ma connaissance il n'y a pas d'outils tout fait qui sache faire cela, >> > ni >> > par stratégie de groupe, je planche actuellement sur un scripts VBS >> > mais >> > c'est vraiment pas évident n'ayant pas été formé dessus, tout ne viens >> > pas >> > naturellement... J'arrive à le faire en locale et de facon pas vraiment >> > optimisé, ce qui me laisse craindre le plantage vu la taille du >> > réseau... >> > >> > Bref si quelqu'un à une idée sur comment je pourrais m'y prendre (pas >> > de >> > MOM >> > désolé ) ou a déjà des scripts dans le style, je suis preneur.>> > >> > D'avance merci ! >> >> |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
sinon pour le fun, en powershell:
$strCategory = "computer" $objDomain = New-Object System.DirectoryServices.DirectoryEntry $objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.SearchRoot = $objDomain $objSearcher.Filter = ("(objectCategory=$strCategory)") $colProplist = "name" foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i )} $colResults = $objSearcher.FindAll() foreach ($objResult in $colResults) { $temp=[System.ServiceProcess.ServiceController]::GetServices($objComputer.name) | where{$_.name -eq 'Dhcp'} If($temp.status -eq "Running") { Write-host $objComputer.name } } -- Cordialement, Mathieu CHATEAU http://lordoftheping.blogspot.com "Mathieu CHATEAU" <gollum123@free.fr> wrote in message news:B46E500D-9278-4783-AB43-C91B362573A9@microsoft.com... > ce script n'est pas en powershell mais bien en VBS > > -- > Cordialement, > Mathieu CHATEAU > http://lordoftheping.blogspot.com > > > "Alexfoo" <Alexfoo@discussions.microsoft.com> wrote in message > news:1AC140E2-308D-4325-A4A8-BDB623A97223@microsoft.com... >> Merci pour votre aide, dès que j'ai le temps je me documente sur >> Powershell >> et je me plonge sur ce script qui à l'air tres complet. >> >> Je vous tiens au courant de mes avancés, encore une fois merci. >> >> "Mathieu CHATEAU" a écrit : >> >>> '================================================= ========================= >>> ' >>> ' >>> ' NAME: <ListComputerUsingParticularService.vbs> >>> ' >>> ' AUTHOR: Ed Wilson , MS >>> ' DATE : 8/14/2006 >>> ' >>> ' COMMENT: <Reports using win32_Service class> >>> '1. will list all services using a particular startup account. >>> '================================================= ========================= >>> >>> Option Explicit >>> 'On Error Resume Next >>> dim strComputer >>> dim wmiNS >>> dim wmiQuery >>> dim objWMIService >>> Dim objLocator >>> dim colItems >>> dim objItem >>> Dim strUsr, strPWD, strLocl, strAuth, iFLag 'connect server parameters >>> Dim colNamedArguments 'WshNamed object >>> Dim strName 'service Name >>> >>> subCheckCscript 'check to see if running in cscript >>> Set colNamedArguments = WScript.Arguments.Named >>> strComputer = colNamedArguments("c") >>> strName = colNamedArguments("s") 'the service name >>> subCheckArguments >>> >>> wmiNS = "\root\cimv2" >>> >>> wmiQuery = "Select name,state from win32_Service where Name = '" & >>> strName & >>> "'" >>> strUsr = colNamedArguments("u") '""'Blank for current security. >>> Domain\Username >>> strPWD = colNamedArguments("p") '""'Blank for current security. >>> strLocl = "" '"MS_409" 'US English. Can leave blank for current language >>> strAuth = ""'if specify domain in strUsr this must be blank >>> iFlag = "0" 'only two values allowed here: 0 (wait for connection) 128 >>> (wait >>> max two min) >>> >>> Set objLocator = CreateObject("WbemScripting.SWbemLocator") >>> Set objWMIService = objLocator.ConnectServer(strComputer, _ >>> wmiNS, strUsr, strPWD, strLocl, strAuth, iFLag) >>> >>> Select Case strName >>> Case "a" >>> wmiQuery = "Select name,state from win32_Service" >>> Case "r" >>> wmiQuery = "Select name,state from win32_Service where state = >>> 'running'" >>> Case "s" >>> wmiQuery = "Select name,state from win32_Service where state = >>> 'stopped'" >>> Case Else >>> wmiQuery = "Select name,state from win32_Service where Name = '" & >>> strName & >>> "'" >>> End Select >>> >>> Set colItems = objWMIService.ExecQuery(wmiQuery) >>> For Each objItem in colItems >>> If objItem.state = "Running" Then >>> Wscript.Echo "Service: " & objItem.name & " is running on " & >>> strComputer >>> Else >>> WScript.Echo "Service: " & objItem.name & " is not running on " & >>> strComputer >>> End If >>> Next >>> >>> >>> ' *** subs are below *** >>> Sub subCheckCscript >>> If UCase(Right(Wscript.FullName, 11)) = "WSCRIPT.EXE" Then >>> Wscript.Echo "This script must be run under CScript" >>> WScript.Quit >>> End If >>> end Sub >>> >>> Sub subCheckArguments >>> >>> If colNamedArguments.Count < 6 Then >>> If colNamedArguments.Exists("?") Then >>> WScript.Echo "Uses win32_Service to identify a running service" _ >>> & VbCrLf & "This script can take arguments. It will identify a computer >>> running a service"_ >>> & VbCrLf & "If you supply the script with a list of computer names, >>> then it >>> will check each" _ >>> & VbCrLf & "computer to see if it is running a particular service. This >>> is >>> useful from both" _ >>> & VbCrLf & "a security and an administrative perspective. This script >>> can >>> run local or remote" _ >>> & VbCrLf & "The service name to query is the registered name NOT the >>> friendly name. As an " _ >>> & VbCrLf & "example: the server service is registered as lanmanserver" >>> _ >>> & VbCrLf & "Alternate credentials can ONLY be supplied for remote >>> connections" _ >>> & VbCrLf & "Try this: cscript " & WScript.ScriptName & " >>> [/s:serviceName, >>> a(all),r(running),s(stopped)] [/c:computername]" _ >>> & " [/u:domainName\UserName] [/p:password]" _ >>> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " >>> /s:alerter" >>> _ >>> & VbCrLf & vbTab & "Displays the status of the alerter service on local >>> machine." _ >>> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " >>> /s:alerter >>> /c:london" _ >>> & VbCrLf & vbTab & "/u:nwtraders\myUser /p:myPassword" _ >>> & VbCrLf & vbTab & "Displays the status of the alterter service on a >>> remote >>> machine" _ >>> & VbCrLf & vbTab & "called London. Connects using myUser account from >>> NWTraders domain." _ >>> & VbCrLf & vbTab & "the password supplied for the connection is >>> myPassword" >>> _ >>> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:r" _ >>> & VbCrLf & vbTab & "Displays list of all running services on local >>> machine." _ >>> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:s" _ >>> & VbCrLf & vbTab & "Displays list of all stopped services on local >>> machine." >>> WScript.Quit >>> End If >>> If Not colNamedArguments.Exists("c") Then >>> WScript.Echo "Executing on Local Machine only" >>> strComputer = "localHost" >>> End If >>> If Not colNamedArguments.Exists("u") Then >>> WScript.Echo "Executing using current user name" >>> strUsr = "" >>> End If >>> If Not colNamedArguments.Exists("p") Then >>> WScript.Echo "Executing using current user password" >>> strPWD = "" >>> End If >>> If Not colNamedArguments.Exists("s") Then >>> WScript.Echo "Using Defaults: status of all services" >>> WScript.Echo "To see try this: cscript ",WScript.ScriptName, " >>> /?" >>> strName = "a" >>> End If >>> End If >>> If colNamedArguments.Count = 0 Then >>> Exit Sub >>> End If >>> End Sub >>> >>> -- >>> Cordialement, >>> Mathieu CHATEAU >>> http://lordoftheping.blogspot.com >>> >>> >>> "Alexfoo" <Alexfoo@discussions.microsoft.com> wrote in message >>> news:A71026FD-8F9F-4CE5-9E8B-B681862439AE@microsoft.com... >>> > Bonjour, >>> > >>> > Je ne sais pas si je poste dans le bon forum... Alors voila, je >>> > travail >>> > actuellement dans un AD, et je dois faire une liste des clients >>> > (uniquement >>> > XP) sur lesquels un certain service est installé. Comme ca ca a l'air >>> > plutot >>> > simple, mais en fait je ne vois pas trop comment m'y prendre... >>> > >>> > A ma connaissance il n'y a pas d'outils tout fait qui sache faire >>> > cela, ni >>> > par stratégie de groupe, je planche actuellement sur un scripts VBS >>> > mais >>> > c'est vraiment pas évident n'ayant pas été formé dessus, tout ne viens >>> > pas >>> > naturellement... J'arrive à le faire en locale et de facon pas >>> > vraiment >>> > optimisé, ce qui me laisse craindre le plantage vu la taille du >>> > réseau... >>> > >>> > Bref si quelqu'un à une idée sur comment je pourrais m'y prendre (pas >>> > de >>> > MOM >>> > désolé ) ou a déjà des scripts dans le style, je suis preneur.>>> > >>> > D'avance merci ! >>> >>> > |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
Arf, je suis pas un pro en VBS ni en powershell mais j'vais deviné !!!
![]() "Mathieu CHATEAU" a écrit : > ce script n'est pas en powershell mais bien en VBS > > -- > Cordialement, > Mathieu CHATEAU > http://lordoftheping.blogspot.com > > > "Alexfoo" <Alexfoo@discussions.microsoft.com> wrote in message > news:1AC140E2-308D-4325-A4A8-BDB623A97223@microsoft.com... > > Merci pour votre aide, dès que j'ai le temps je me documente sur > > Powershell > > et je me plonge sur ce script qui à l'air tres complet. > > > > Je vous tiens au courant de mes avancés, encore une fois merci. > > > > "Mathieu CHATEAU" a écrit : > > > >> '================================================= ========================= > >> ' > >> ' > >> ' NAME: <ListComputerUsingParticularService.vbs> > >> ' > >> ' AUTHOR: Ed Wilson , MS > >> ' DATE : 8/14/2006 > >> ' > >> ' COMMENT: <Reports using win32_Service class> > >> '1. will list all services using a particular startup account. > >> '================================================= ========================= > >> > >> Option Explicit > >> 'On Error Resume Next > >> dim strComputer > >> dim wmiNS > >> dim wmiQuery > >> dim objWMIService > >> Dim objLocator > >> dim colItems > >> dim objItem > >> Dim strUsr, strPWD, strLocl, strAuth, iFLag 'connect server parameters > >> Dim colNamedArguments 'WshNamed object > >> Dim strName 'service Name > >> > >> subCheckCscript 'check to see if running in cscript > >> Set colNamedArguments = WScript.Arguments.Named > >> strComputer = colNamedArguments("c") > >> strName = colNamedArguments("s") 'the service name > >> subCheckArguments > >> > >> wmiNS = "\root\cimv2" > >> > >> wmiQuery = "Select name,state from win32_Service where Name = '" & > >> strName & > >> "'" > >> strUsr = colNamedArguments("u") '""'Blank for current security. > >> Domain\Username > >> strPWD = colNamedArguments("p") '""'Blank for current security. > >> strLocl = "" '"MS_409" 'US English. Can leave blank for current language > >> strAuth = ""'if specify domain in strUsr this must be blank > >> iFlag = "0" 'only two values allowed here: 0 (wait for connection) 128 > >> (wait > >> max two min) > >> > >> Set objLocator = CreateObject("WbemScripting.SWbemLocator") > >> Set objWMIService = objLocator.ConnectServer(strComputer, _ > >> wmiNS, strUsr, strPWD, strLocl, strAuth, iFLag) > >> > >> Select Case strName > >> Case "a" > >> wmiQuery = "Select name,state from win32_Service" > >> Case "r" > >> wmiQuery = "Select name,state from win32_Service where state = 'running'" > >> Case "s" > >> wmiQuery = "Select name,state from win32_Service where state = 'stopped'" > >> Case Else > >> wmiQuery = "Select name,state from win32_Service where Name = '" & > >> strName & > >> "'" > >> End Select > >> > >> Set colItems = objWMIService.ExecQuery(wmiQuery) > >> For Each objItem in colItems > >> If objItem.state = "Running" Then > >> Wscript.Echo "Service: " & objItem.name & " is running on " & > >> strComputer > >> Else > >> WScript.Echo "Service: " & objItem.name & " is not running on " & > >> strComputer > >> End If > >> Next > >> > >> > >> ' *** subs are below *** > >> Sub subCheckCscript > >> If UCase(Right(Wscript.FullName, 11)) = "WSCRIPT.EXE" Then > >> Wscript.Echo "This script must be run under CScript" > >> WScript.Quit > >> End If > >> end Sub > >> > >> Sub subCheckArguments > >> > >> If colNamedArguments.Count < 6 Then > >> If colNamedArguments.Exists("?") Then > >> WScript.Echo "Uses win32_Service to identify a running service" _ > >> & VbCrLf & "This script can take arguments. It will identify a computer > >> running a service"_ > >> & VbCrLf & "If you supply the script with a list of computer names, then > >> it > >> will check each" _ > >> & VbCrLf & "computer to see if it is running a particular service. This > >> is > >> useful from both" _ > >> & VbCrLf & "a security and an administrative perspective. This script > >> can > >> run local or remote" _ > >> & VbCrLf & "The service name to query is the registered name NOT the > >> friendly name. As an " _ > >> & VbCrLf & "example: the server service is registered as lanmanserver" _ > >> & VbCrLf & "Alternate credentials can ONLY be supplied for remote > >> connections" _ > >> & VbCrLf & "Try this: cscript " & WScript.ScriptName & " > >> [/s:serviceName, > >> a(all),r(running),s(stopped)] [/c:computername]" _ > >> & " [/u:domainName\UserName] [/p:password]" _ > >> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " > >> /s:alerter" > >> _ > >> & VbCrLf & vbTab & "Displays the status of the alerter service on local > >> machine." _ > >> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " > >> /s:alerter > >> /c:london" _ > >> & VbCrLf & vbTab & "/u:nwtraders\myUser /p:myPassword" _ > >> & VbCrLf & vbTab & "Displays the status of the alterter service on a > >> remote > >> machine" _ > >> & VbCrLf & vbTab & "called London. Connects using myUser account from > >> NWTraders domain." _ > >> & VbCrLf & vbTab & "the password supplied for the connection is > >> myPassword" > >> _ > >> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:r" _ > >> & VbCrLf & vbTab & "Displays list of all running services on local > >> machine." _ > >> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:s" _ > >> & VbCrLf & vbTab & "Displays list of all stopped services on local > >> machine." > >> WScript.Quit > >> End If > >> If Not colNamedArguments.Exists("c") Then > >> WScript.Echo "Executing on Local Machine only" > >> strComputer = "localHost" > >> End If > >> If Not colNamedArguments.Exists("u") Then > >> WScript.Echo "Executing using current user name" > >> strUsr = "" > >> End If > >> If Not colNamedArguments.Exists("p") Then > >> WScript.Echo "Executing using current user password" > >> strPWD = "" > >> End If > >> If Not colNamedArguments.Exists("s") Then > >> WScript.Echo "Using Defaults: status of all services" > >> WScript.Echo "To see try this: cscript ",WScript.ScriptName, " /?" > >> strName = "a" > >> End If > >> End If > >> If colNamedArguments.Count = 0 Then > >> Exit Sub > >> End If > >> End Sub > >> > >> -- > >> Cordialement, > >> Mathieu CHATEAU > >> http://lordoftheping.blogspot.com > >> > >> > >> "Alexfoo" <Alexfoo@discussions.microsoft.com> wrote in message > >> news:A71026FD-8F9F-4CE5-9E8B-B681862439AE@microsoft.com... > >> > Bonjour, > >> > > >> > Je ne sais pas si je poste dans le bon forum... Alors voila, je travail > >> > actuellement dans un AD, et je dois faire une liste des clients > >> > (uniquement > >> > XP) sur lesquels un certain service est installé. Comme ca ca a l'air > >> > plutot > >> > simple, mais en fait je ne vois pas trop comment m'y prendre... > >> > > >> > A ma connaissance il n'y a pas d'outils tout fait qui sache faire cela, > >> > ni > >> > par stratégie de groupe, je planche actuellement sur un scripts VBS > >> > mais > >> > c'est vraiment pas évident n'ayant pas été formé dessus, tout ne viens > >> > pas > >> > naturellement... J'arrive à le faire en locale et de facon pas vraiment > >> > optimisé, ce qui me laisse craindre le plantage vu la taille du > >> > réseau... > >> > > >> > Bref si quelqu'un à une idée sur comment je pourrais m'y prendre (pas > >> > de > >> > MOM > >> > désolé ) ou a déjà des scripts dans le style, je suis preneur.> >> > > >> > D'avance merci ! > >> > >> > > |
|
|
|
#11 |
|
Messages: n/a
Hébergeur: |
Bon il fonctionne tres bien et très complet en local... je n'arrive pas Ã
l'utiliser en remote, j'ai l'erreur "C:\Documents\service.vbs(44, 1)" SWbemLocator: Accès refusé. la ligne (44.1) correspond à Set objWMIService = objLocator.ConnectServer(strComputer, _ wmiNS, strUsr, strPWD, strLocl, strAuth, iFLag) Les firewalls sont désactivés, et sur les logs sécurité da la machine distante il y a une entrée en "Succès" avec le compte utilisé dans le script... j'en perds mon latin pour etre franc. "Alexfoo" a écrit : > Arf, je suis pas un pro en VBS ni en powershell mais j'vais deviné !!! ![]() > > "Mathieu CHATEAU" a écrit : > > > ce script n'est pas en powershell mais bien en VBS > > > > -- > > Cordialement, > > Mathieu CHATEAU > > http://lordoftheping.blogspot.com > > > > > > "Alexfoo" <Alexfoo@discussions.microsoft.com> wrote in message > > news:1AC140E2-308D-4325-A4A8-BDB623A97223@microsoft.com... > > > Merci pour votre aide, dès que j'ai le temps je me documente sur > > > Powershell > > > et je me plonge sur ce script qui à l'air tres complet. > > > > > > Je vous tiens au courant de mes avancés, encore une fois merci. > > > > > > "Mathieu CHATEAU" a écrit : > > > > > >> '================================================= ========================= > > >> ' > > >> ' > > >> ' NAME: <ListComputerUsingParticularService.vbs> > > >> ' > > >> ' AUTHOR: Ed Wilson , MS > > >> ' DATE : 8/14/2006 > > >> ' > > >> ' COMMENT: <Reports using win32_Service class> > > >> '1. will list all services using a particular startup account. > > >> '================================================= ========================= > > >> > > >> Option Explicit > > >> 'On Error Resume Next > > >> dim strComputer > > >> dim wmiNS > > >> dim wmiQuery > > >> dim objWMIService > > >> Dim objLocator > > >> dim colItems > > >> dim objItem > > >> Dim strUsr, strPWD, strLocl, strAuth, iFLag 'connect server parameters > > >> Dim colNamedArguments 'WshNamed object > > >> Dim strName 'service Name > > >> > > >> subCheckCscript 'check to see if running in cscript > > >> Set colNamedArguments = WScript.Arguments.Named > > >> strComputer = colNamedArguments("c") > > >> strName = colNamedArguments("s") 'the service name > > >> subCheckArguments > > >> > > >> wmiNS = "\root\cimv2" > > >> > > >> wmiQuery = "Select name,state from win32_Service where Name = '" & > > >> strName & > > >> "'" > > >> strUsr = colNamedArguments("u") '""'Blank for current security. > > >> Domain\Username > > >> strPWD = colNamedArguments("p") '""'Blank for current security. > > >> strLocl = "" '"MS_409" 'US English. Can leave blank for current language > > >> strAuth = ""'if specify domain in strUsr this must be blank > > >> iFlag = "0" 'only two values allowed here: 0 (wait for connection) 128 > > >> (wait > > >> max two min) > > >> > > >> Set objLocator = CreateObject("WbemScripting.SWbemLocator") > > >> Set objWMIService = objLocator.ConnectServer(strComputer, _ > > >> wmiNS, strUsr, strPWD, strLocl, strAuth, iFLag) > > >> > > >> Select Case strName > > >> Case "a" > > >> wmiQuery = "Select name,state from win32_Service" > > >> Case "r" > > >> wmiQuery = "Select name,state from win32_Service where state = 'running'" > > >> Case "s" > > >> wmiQuery = "Select name,state from win32_Service where state = 'stopped'" > > >> Case Else > > >> wmiQuery = "Select name,state from win32_Service where Name = '" & > > >> strName & > > >> "'" > > >> End Select > > >> > > >> Set colItems = objWMIService.ExecQuery(wmiQuery) > > >> For Each objItem in colItems > > >> If objItem.state = "Running" Then > > >> Wscript.Echo "Service: " & objItem.name & " is running on " & > > >> strComputer > > >> Else > > >> WScript.Echo "Service: " & objItem.name & " is not running on " & > > >> strComputer > > >> End If > > >> Next > > >> > > >> > > >> ' *** subs are below *** > > >> Sub subCheckCscript > > >> If UCase(Right(Wscript.FullName, 11)) = "WSCRIPT.EXE" Then > > >> Wscript.Echo "This script must be run under CScript" > > >> WScript.Quit > > >> End If > > >> end Sub > > >> > > >> Sub subCheckArguments > > >> > > >> If colNamedArguments.Count < 6 Then > > >> If colNamedArguments.Exists("?") Then > > >> WScript.Echo "Uses win32_Service to identify a running service" _ > > >> & VbCrLf & "This script can take arguments. It will identify a computer > > >> running a service"_ > > >> & VbCrLf & "If you supply the script with a list of computer names, then > > >> it > > >> will check each" _ > > >> & VbCrLf & "computer to see if it is running a particular service. This > > >> is > > >> useful from both" _ > > >> & VbCrLf & "a security and an administrative perspective. This script > > >> can > > >> run local or remote" _ > > >> & VbCrLf & "The service name to query is the registered name NOT the > > >> friendly name. As an " _ > > >> & VbCrLf & "example: the server service is registered as lanmanserver" _ > > >> & VbCrLf & "Alternate credentials can ONLY be supplied for remote > > >> connections" _ > > >> & VbCrLf & "Try this: cscript " & WScript.ScriptName & " > > >> [/s:serviceName, > > >> a(all),r(running),s(stopped)] [/c:computername]" _ > > >> & " [/u:domainName\UserName] [/p:password]" _ > > >> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " > > >> /s:alerter" > > >> _ > > >> & VbCrLf & vbTab & "Displays the status of the alerter service on local > > >> machine." _ > > >> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " > > >> /s:alerter > > >> /c:london" _ > > >> & VbCrLf & vbTab & "/u:nwtraders\myUser /p:myPassword" _ > > >> & VbCrLf & vbTab & "Displays the status of the alterter service on a > > >> remote > > >> machine" _ > > >> & VbCrLf & vbTab & "called London. Connects using myUser account from > > >> NWTraders domain." _ > > >> & VbCrLf & vbTab & "the password supplied for the connection is > > >> myPassword" > > >> _ > > >> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:r" _ > > >> & VbCrLf & vbTab & "Displays list of all running services on local > > >> machine." _ > > >> & VbCrLf & vbTab & "Example: cscript " & WScript.ScriptName & " /s:s" _ > > >> & VbCrLf & vbTab & "Displays list of all stopped services on local > > >> machine." > > >> WScript.Quit > > >> End If > > >> If Not colNamedArguments.Exists("c") Then > > >> WScript.Echo "Executing on Local Machine only" > > >> strComputer = "localHost" > > >> End If > > >> If Not colNamedArguments.Exists("u") Then > > >> WScript.Echo "Executing using current user name" > > >> strUsr = "" > > >> End If > > >> If Not colNamedArguments.Exists("p") Then > > >> WScript.Echo "Executing using current user password" > > >> strPWD = "" > > >> End If > > >> If Not colNamedArguments.Exists("s") Then > > >> WScript.Echo "Using Defaults: status of all services" > > >> WScript.Echo "To see try this: cscript ",WScript.ScriptName, " /?" > > >> strName = "a" > > >> End If > > >> End If > > >> If colNamedArguments.Count = 0 Then > > >> Exit Sub > > >> End If > > >> End Sub > > >> > > >> -- > > >> Cordialement, > > >> Mathieu CHATEAU > > >> http://lordoftheping.blogspot.com > > >> > > >> > > >> "Alexfoo" <Alexfoo@discussions.microsoft.com> wrote in message > > >> news:A71026FD-8F9F-4CE5-9E8B-B681862439AE@microsoft.com... > > >> > Bonjour, > > >> > > > >> > Je ne sais pas si je poste dans le bon forum... Alors voila, je travail > > >> > actuellement dans un AD, et je dois faire une liste des clients > > >> > (uniquement > > >> > XP) sur lesquels un certain service est installé. Comme ca ca a l'air > > >> > plutot > > >> > simple, mais en fait je ne vois pas trop comment m'y prendre... > > >> > > > >> > A ma connaissance il n'y a pas d'outils tout fait qui sache faire cela, > > >> > ni > > >> > par stratégie de groupe, je planche actuellement sur un scripts VBS > > >> > mais > > >> > c'est vraiment pas évident n'ayant pas été formé dessus, tout ne viens > > >> > pas > > >> > naturellement... J'arrive à le faire en locale et de facon pas vraiment > > >> > optimisé, ce qui me laisse craindre le plantage vu la taille du > > >> > réseau... > > >> > > > >> > Bref si quelqu'un à une idée sur comment je pourrais m'y prendre (pas > > >> > de > > >> > MOM > > >> > désolé ) ou a déjà des scripts dans le style, je suis preneur.> > >> > > > >> > D'avance merci ! > > >> > > >> > > > > |
|
|
|
#12 |
|
Messages: n/a
Hébergeur: |
est-ce que le compte utilisateur qui lance le script est un compte du domaine AD ? Administrateur local de la machine cible (optionnel, je l'espère) ? -- Cordialement, Mathieu CHATEAU http://lordoftheping.blogspot.com "Alexfoo" <Alexfoo@discussions.microsoft.com> wrote in message news:3CD88936-90CF-4033-8023-A20961D0BB29@microsoft.com... > Bon il fonctionne tres bien et très complet en local... je n'arrive pas à > l'utiliser en remote, j'ai l'erreur > "C:\Documents\service.vbs(44, 1)" > SWbemLocator: Accès refusé. > > la ligne (44.1) correspond à > Set objWMIService = objLocator.ConnectServer(strComputer, _ > wmiNS, strUsr, strPWD, strLocl, strAuth, iFLag) > > Les firewalls sont désactivés, et sur les logs sécurité da la machine > distante il y a une entrée en "Succès" avec le compte utilisé dans le > script... j'en perds mon latin pour etre franc. > > "Alexfoo" a écrit : > >> Arf, je suis pas un pro en VBS ni en powershell mais j'vais deviné !!! >> ![]() >> >> "Mathieu CHATEAU" a écrit : >> >> > ce script n'est pas en powershell mais bien en VBS >> > >> > -- >> > Cordialement, >> > Mathieu CHATEAU >> > http://lordoftheping.blogspot.com >> > >> > >> > "Alexfoo" <Alexfoo@discussions.microsoft.com> wrote in message >> > news:1AC140E2-308D-4325-A4A8-BDB623A97223@microsoft.com... >> > > Merci pour votre aide, dès que j'ai le temps je me documente sur >> & |