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 !
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" <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 !
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 !
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 !
est-ce que le compte utilisateur qui lance le script est un compte du
domaine AD ? Administrateur local de la machine cible (optionnel, je
l'espère) ?
--
Cordialement,
Mathieu CHATEAU
http://lordoftheping.blogspot.com
"Alexfoo" <Alexfoo@discussions.microsoft.com> wrote in message
news:3CD88936-90CF-4033-8023-A20961D0BB29@microsoft.com...
Bon il fonctionne tres bien et très complet en local... je n'arrive pas à
l'utiliser en remote, j'ai l'erreur
"C: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" <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 !
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 !
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
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
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
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
$name
gwmi Win32_PS C:> foreach ($name in $names) {
$name
gwmi Win32_OperatingSystem -prop ServicePackMajorVersion
-comp $name
}
(...)
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
$name
gwmi Win32_PS C:> foreach ($name in $names) {
$name
gwmi Win32_OperatingSystem -prop ServicePackMajorVersion
-comp $name
}
(...)
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
$name
gwmi Win32_PS C:> foreach ($name in $names) {
$name
gwmi Win32_OperatingSystem -prop ServicePackMajorVersion
-comp $name
}
(...)