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 !
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 !
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 !
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 !
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 !
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 !
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/scriptcenter/scripts/default.mspx?mfr=true
ou là
http://www.microsoft.com/technet/scriptcenter/csc/scripts/os/service/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" a écrit dans le message de
news: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 !
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/scriptcenter/scripts/default.mspx?mfr=true
ou là
http://www.microsoft.com/technet/scriptcenter/csc/scripts/os/service/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 !
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/scriptcenter/scripts/default.mspx?mfr=true
ou là
http://www.microsoft.com/technet/scriptcenter/csc/scripts/os/service/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" a écrit dans le message de
news: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 !
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...
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...
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...
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 !
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 !
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 !
'========================================================================= > '
'
' 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 = "rootcimv2"
wmiQuery = "Select name,state from win32_Service where Name = '" & strName &
"'"
strUsr = colNamedArguments("u") '""'Blank for current security.
DomainUsername
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:domainNameUserName] [/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:nwtradersmyUser /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 help 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" wrote in message
news: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 !
'========================================================================= > '
'
' 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 = "rootcimv2"
wmiQuery = "Select name,state from win32_Service where Name = '" & strName &
"'"
strUsr = colNamedArguments("u") '""'Blank for current security.
DomainUsername
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:domainNameUserName] [/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:nwtradersmyUser /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 help 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 !
'========================================================================= > '
'
' 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 = "rootcimv2"
wmiQuery = "Select name,state from win32_Service where Name = '" & strName &
"'"
strUsr = colNamedArguments("u") '""'Blank for current security.
DomainUsername
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:domainNameUserName] [/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:nwtradersmyUser /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 help 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" wrote in message
news: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 !
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.'========================================================================= >> '
'
' 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 = "rootcimv2"
wmiQuery = "Select name,state from win32_Service where Name = '" &
strName &
"'"
strUsr = colNamedArguments("u") '""'Blank for current security.
DomainUsername
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:domainNameUserName] [/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:nwtradersmyUser /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 help 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" wrote in message
news: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 !
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.
'========================================================================= >> '
'
' 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 = "rootcimv2"
wmiQuery = "Select name,state from win32_Service where Name = '" &
strName &
"'"
strUsr = colNamedArguments("u") '""'Blank for current security.
DomainUsername
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:domainNameUserName] [/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:nwtradersmyUser /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 help 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 !
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.'========================================================================= >> '
'
' 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 = "rootcimv2"
wmiQuery = "Select name,state from win32_Service where Name = '" &
strName &
"'"
strUsr = colNamedArguments("u") '""'Blank for current security.
DomainUsername
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:domainNameUserName] [/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:nwtradersmyUser /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 help 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" wrote in message
news: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 !
ce script n'est pas en powershell mais bien en VBS
--
Cordialement,
Mathieu CHATEAU
http://lordoftheping.blogspot.com
"Alexfoo" wrote in message
news: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.'========================================================================= >>> '
'
' 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 = "rootcimv2"
wmiQuery = "Select name,state from win32_Service where Name = '" &
strName &
"'"
strUsr = colNamedArguments("u") '""'Blank for current security.
DomainUsername
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:domainNameUserName] [/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:nwtradersmyUser /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 help 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" wrote in message
news: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 !
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.
'========================================================================= >>> '
'
' 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 = "rootcimv2"
wmiQuery = "Select name,state from win32_Service where Name = '" &
strName &
"'"
strUsr = colNamedArguments("u") '""'Blank for current security.
DomainUsername
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:domainNameUserName] [/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:nwtradersmyUser /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 help 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 !
ce script n'est pas en powershell mais bien en VBS
--
Cordialement,
Mathieu CHATEAU
http://lordoftheping.blogspot.com
"Alexfoo" wrote in message
news: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.'========================================================================= >>> '
'
' 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 = "rootcimv2"
wmiQuery = "Select name,state from win32_Service where Name = '" &
strName &
"'"
strUsr = colNamedArguments("u") '""'Blank for current security.
DomainUsername
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:domainNameUserName] [/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:nwtradersmyUser /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 help 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" wrote in message
news: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 !
ce script n'est pas en powershell mais bien en VBS
--
Cordialement,
Mathieu CHATEAU
http://lordoftheping.blogspot.com
"Alexfoo" wrote in message
news: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.'========================================================================= > >> '
'
' 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 = "rootcimv2"
wmiQuery = "Select name,state from win32_Service where Name = '" &
strName &
"'"
strUsr = colNamedArguments("u") '""'Blank for current security.
DomainUsername
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:domainNameUserName] [/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:nwtradersmyUser /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 help 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" wrote in message
news: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 !
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.
'========================================================================= > >> '
'
' 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 = "rootcimv2"
wmiQuery = "Select name,state from win32_Service where Name = '" &
strName &
"'"
strUsr = colNamedArguments("u") '""'Blank for current security.
DomainUsername
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:domainNameUserName] [/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:nwtradersmyUser /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 help 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 !
ce script n'est pas en powershell mais bien en VBS
--
Cordialement,
Mathieu CHATEAU
http://lordoftheping.blogspot.com
"Alexfoo" wrote in message
news: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.'========================================================================= > >> '
'
' 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 = "rootcimv2"
wmiQuery = "Select name,state from win32_Service where Name = '" &
strName &
"'"
strUsr = colNamedArguments("u") '""'Blank for current security.
DomainUsername
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:domainNameUserName] [/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:nwtradersmyUser /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 help 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" wrote in message
news: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 !
Arf, je suis pas un pro en VBS ni en powershell mais j'vais deviné !!! ;)ce script n'est pas en powershell mais bien en VBS
--
Cordialement,
Mathieu CHATEAU
http://lordoftheping.blogspot.com
"Alexfoo" wrote in message
news: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.'========================================================================= > > >> '
'
' 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 = "rootcimv2"
wmiQuery = "Select name,state from win32_Service where Name = '" &
strName &
"'"
strUsr = colNamedArguments("u") '""'Blank for current security.
DomainUsername
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:domainNameUserName] [/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:nwtradersmyUser /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 help 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" wrote in message
news: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 !
Arf, je suis pas un pro en VBS ni en powershell mais j'vais deviné !!! ;)
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.
'========================================================================= > > >> '
'
' 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 = "rootcimv2"
wmiQuery = "Select name,state from win32_Service where Name = '" &
strName &
"'"
strUsr = colNamedArguments("u") '""'Blank for current security.
DomainUsername
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:domainNameUserName] [/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:nwtradersmyUser /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 help 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 !
Arf, je suis pas un pro en VBS ni en powershell mais j'vais deviné !!! ;)ce script n'est pas en powershell mais bien en VBS
--
Cordialement,
Mathieu CHATEAU
http://lordoftheping.blogspot.com
"Alexfoo" wrote in message
news: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.'========================================================================= > > >> '
'
' 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 = "rootcimv2"
wmiQuery = "Select name,state from win32_Service where Name = '" &
strName &
"'"
strUsr = colNamedArguments("u") '""'Blank for current security.
DomainUsername
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:domainNameUserName] [/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:nwtradersmyUser /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 help 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" wrote in message
news: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 !