Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Faire une liste des postes sur lesquels un serive est installé

14 réponses
Avatar
Alexfoo
Bonjour,

Je ne sais pas si je poste dans le bon forum... Alors voila, je travail
actuellement dans un AD, et je dois faire une liste des clients (uniquement
XP) sur lesquels un certain service est installé. Comme ca ca a l'air plutot
simple, mais en fait je ne vois pas trop comment m'y prendre...

A ma connaissance il n'y a pas d'outils tout fait qui sache faire cela, ni
par stratégie de groupe, je planche actuellement sur un scripts VBS mais
c'est vraiment pas évident n'ayant pas été formé dessus, tout ne viens pas
naturellement... J'arrive à le faire en locale et de facon pas vraiment
optimisé, ce qui me laisse craindre le plantage vu la taille du réseau...

Bref si quelqu'un à une idée sur comment je pourrais m'y prendre (pas de MOM
désolé :) ) ou a déjà des scripts dans le style, je suis preneur.

D'avance merci !

10 réponses

1 2
Avatar
Omar_ Abib
Bonjour ,

Votre meilleure solution pour ces scenarion eSt d'utilisez SMS ( Software
management services)
http://www.microsoft.com/smserver/default.mspx
vous pouvez telecharger la version d'evaluation et vous allez vois ce que
vous pouvez faite avec .


Omar

"Alexfoo" 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 !


Avatar
Jonathan BISMUTH
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 !


Avatar
Alexfoo
Merci Omar, j'avais déjà pensé à SMS, malheureusement il n'est pas possible
d'ajouter de nouveaux agents sur les postes... y'en a déjà pour l'antivirus,
le déploiement et le firewall... trop lourd à gérer...

Pour ce qui est des scripts biensûr j'ai déjà regardé le "scripcenter" et
"scriptomatic", le probleme est que les scripts proposés ont TOUS la meme
structure , à savoir un "select *", suivit d'un "pour chaque entrée de chaque
occurence renvoyé par la requete", affiché ceci...

Hors la syntaxe WMI & VBS est casse c*** pour faire des choses toutes
simples en langages classiques (VB6, .NET, etc...) c'est la croix et la
bannière j'ai du mal...

Bon enfin apparement il va falloir que je persiste dans cette voix, merci
quand meme !


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 !







Avatar
Jacques Barathon [MS]
"Alexfoo" wrote in message
news:
Merci Omar, j'avais déjà pensé à SMS, malheureusement il n'est pas
possible
d'ajouter de nouveaux agents sur les postes... y'en a déjà pour
l'antivirus,
le déploiement et le firewall... trop lourd à gérer...

Pour ce qui est des scripts biensûr j'ai déjà regardé le "scripcenter" et
"scriptomatic", le probleme est que les scripts proposés ont TOUS la meme
structure , à savoir un "select *", suivit d'un "pour chaque entrée de
chaque
occurence renvoyé par la requete", affiché ceci...

Hors la syntaxe WMI & VBS est casse c*** pour faire des choses toutes
simples en langages classiques (VB6, .NET, etc...) c'est la croix et la
bannière j'ai du mal...


Si tu as une expérience même petite en programmation "classique" et que tu
es encore novice en matière de scripting pour Windows, je te conseille de te
mettre plutôt à Windows PowerShell, environnement sur lequel Microsoft
concentre ses efforts pour le scripting dans les années à venir.

Avec PowerShell, la requête dont tu as besoin ne devrait pas être plus
longue que deux ou trois commandes: une pour récupérer tous les ordinateurs
de l'AD (requête ADSI), une pour interroger chaque ordinateur récupéré sur
la présence ou non du service en question (requête WMI), et éventuellement
une commande pour formater le résultat. Et puis allez, ajoutons une
quatrième commande pour écrire le résultat dans un fichier.

Pour installer PowerShell:
http://www.microsoft.com/downloads/results.aspx?pocId=&freetext=powershell&DisplayLang=fr.

Tu n'as besoin d'installer PowerShell que sur le poste à partir duquel tu
lanceras ton script. Il suffit que ce poste ait accès à l'AD et aux
ordinateurs à interroger, et que le compte qui lance le script ait les
autorisations nécessaires.

Si tu n'y arrives pas, repose la question sur le forum de scripting - comme
suggéré par Jonathan, il est plus adapté pour ce genre de problématique.

Jacques

Avatar
Mathieu CHATEAU
'========================================================================= '
'
' 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 !


Avatar
Alexfoo
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 !






Avatar
Mathieu CHATEAU
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 !








Avatar
Mathieu CHATEAU
sinon pour le fun, en powershell:

$strCategory = "computer"
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.Filter = ("(objectCategory=$strCategory)")
$colProplist = "name"
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}
$colResults = $objSearcher.FindAll()
foreach ($objResult in $colResults)
{
$temp=[System.ServiceProcess.ServiceController]::GetServices($objComputer.name)
| where{$_.name -eq 'Dhcp'}
If($temp.status -eq "Running")
{
Write-host $objComputer.name
}
}

--
Cordialement,
Mathieu CHATEAU
http://lordoftheping.blogspot.com


"Mathieu CHATEAU" wrote in message
news:
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 !











Avatar
Alexfoo
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 !












Avatar
Alexfoo
Bon il fonctionne tres bien et très complet en local... je n'arrive pas à
l'utiliser en remote, j'ai l'erreur
"C:Documentsservice.vbs(44, 1)"
SWbemLocator: Accès refusé.

la ligne (44.1) correspond à
Set objWMIService = objLocator.ConnectServer(strComputer, _
wmiNS, strUsr, strPWD, strLocl, strAuth, iFLag)

Les firewalls sont désactivés, et sur les logs sécurité da la machine
distante il y a une entrée en "Succès" avec le compte utilisé dans le
script... j'en perds mon latin pour etre franc.


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 !














1 2