PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.win.server.scripting > Machine Account Group Membership: How to...
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Machine Account Group Membership: How to...

Réponse
 
LinkBack Outils de la discussion
Vieux 06/10/2007, 04h37   #1
rmfisher@aquadog.net
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Machine Account Group Membership: How to...

Hello, I have been looking all over, and I can't seem to find anything
close to what I need. I am looking for a way to run a script that
executes something based on the Machine Account group membership. So,
the logic would be something like:

if MACHINEACCOUNT is member of group "XP Machines"
run job.bat
else
run otherjob.bat

Sorry for my poor skills shown there! I really don't know much about
scripting, and the little I can figure out can't get me what I need.
also, I would really prefer it to run in a batch file, because that is
how it is all set up already.

I really appreciate any from anyone! Thanks much!

  Réponse avec citation
Vieux 06/10/2007, 14h42   #2
Richard Mueller [MVP]
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Machine Account Group Membership: How to...


<rmfisher@aquadog.net> wrote in message
news:1191638250.945873.289190@o80g2000hse.googlegr oups.com...
> Hello, I have been looking all over, and I can't seem to find anything
> close to what I need. I am looking for a way to run a script that
> executes something based on the Machine Account group membership. So,
> the logic would be something like:
>
> if MACHINEACCOUNT is member of group "XP Machines"
> run job.bat
> else
> run otherjob.bat
>
> Sorry for my poor skills shown there! I really don't know much about
> scripting, and the little I can figure out can't get me what I need.
> also, I would really prefer it to run in a batch file, because that is
> how it is all set up already.
>
> I really appreciate any from anyone! Thanks much!
>


Testing for computer group membership is just like for user group
membership. To do this in a batch file you need a third party tool. I
believe the IfMember utility is available on the Microsoft web site (it used
to be in the NT resource kit). There is also a product called KiXstart.

In VBScript you would bind to the computer and group objects, then use the
IsMember method of the group. For example:
==============
' Bind to computer object.
Set objComputer =
GetObject("LDAP://cn=TestComputer,ou=West,dc=MyDomain,dc=com")

' Bind to group object.
Set objGroup = GetObject("LDAP://cn=MyGroup,ou=West,dc=MyDomain,dc=com")

' Test for membership in the group.
If (objGroup.IsMember(objUser.AdsPath) = True) Then
' Do something.
End If
============
Usually the computer is the local computer, not a remote machine. For
example, this is often done in a logon script. To bind to the local computer
use:
===========
' Retrieve DN of local computer from ADSystemInfo object.
Set objSysInfo = CreateObject("ADSystemInfo")
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
=========
To run another program from VBScript, you can use the Run method of the
Shell object. For example:
=========
Set objShell = CreateObject("Wscript.Shell")
objShell.Run("%comspec% /c c:\Scripts\job.bat", 0)
=========
I hope this s.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h26.


Édité par : vBulletin® version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09852 seconds with 10 queries