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 !

4 réponses

1 2
Avatar
Mathieu CHATEAU
est-ce que le compte utilisateur qui lance le script est un compte du
domaine AD ? Administrateur local de la machine cible (optionnel, je
l'espère) ?




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


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
















Avatar
Alexfoo
J'ai essayé avec un compte admin du domaine et le compte administrateur de la
machine avec le meme résultat...

D'apres les recherches que j'a fais biensûr il faut un compte avec des
droits admins ainsi que des autorisations spécifiques, mais je n'ai pas
trouvé lesquelles.


est-ce que le compte utilisateur qui lance le script est un compte du
domaine AD ? Administrateur local de la machine cible (optionnel, je
l'espère) ?




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


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



















Avatar
F. Dunoyer [MVP]
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 .
Desolé mais SMS ne me parait pas une bonne idée

C'est un produit plutot complexe et cher.
Il n'est interessant que sur de grands parcs machines (plus de 500 pc)
et pas évident a mettre en place

les solutions de scripting me paraissent plus adaptées si le soucis
n'est que d'identifier un service


--
François Dunoyer [MVP Windows Server / Security]
Jours après jours avec Longhorn Server
http://fds.mvps.org/LH/index.htm

Avatar
THP
On 23 juil, 01:19, F. Dunoyer [MVP] <wdunoyer-
~.net> wrote:
Après mure réflexion, Omar_ Abib a écrit :> Bonjour ,

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


Desolé mais SMS ne me parait pas une bonne idée
C'est un produit plutot complexe et cher.
Il n'est interessant que sur de grands parcs machines (plus de 500 pc)
et pas évident a mettre en place

les solutions de scripting me paraissent plus adaptées si le soucis
n'est que d'identifier un service

--
François Dunoyer [MVP Windows Server / Security]
Jours après jours avec Longhorn Serverhttp://fds.mvps.org/LH/index.htm



Bonjour,

Oui, SMS c'est trop cher pour ne faire que ca !
Pourquoi ne pas utiliser powershell ?

un fichier pour la liste des pc
un get-content pour lire cette liste
une boucle pour se connecter a chaque pc de la liste
un get-wmiobject win32_service -computer "variable qui represnte le
computer dans la boucle" | where { $_.servicename -eq "nom du
service"}
en fonction de ce qu'on veut faire, on rajoute ceci a une liste ou on
cree un fichier par machine ...

Powershell est gratuit, il necessite le framework 2 sur la machine sur
laquelle tu installes powershell
QUi plus est, l'apprendre constitue un bon investissement puisque
exchange 2007, DPM v2, SCOM 2007, ..... l'utilisent déjà

sur le site de Microsoft, j'ai trouvé ceci qui ressemble tres fort a
ce que tu devras faire ....

(...)Windows PowerShell lets
you break this into something more readable, which you can type
directly into the shell without ever writing a script. Here's how it
might look:
PS C:> $names = get-content "c:computers.txt"
PS C:> foreach ($name in $names) {
$name
gwmi Win32_PS C:> foreach ($name in $names) {
$name
gwmi Win32_OperatingSystem -prop ServicePackMajorVersion
-comp $name


}

(...)


http://download.microsoft.com/documents/uk/technet/downloads/technetmagazin e/issue4/68_PowerShell.pdf
Il tape ceci en interactif. Par defaut, powershell ne lance pas ses
scripts ...

Cordialement,


1 2