Jump to content

Recommended Posts

Posted

i currently have a printer script that looks at the hostname of the computer and uses that to work out what printers it needs.

 

is it possible to pickup what AD Group the machine is in, that way its much easier when i swap machines around.

Posted

'Connect to AD
Set objSysInfo = CreateObject("ADSystemInfo")


'Get LDAP entry to current computer object.
strComputerDN = objSysInfo.ComputerName
Set objComputer = GetObject("LDAP://" & strComputerDN)
'WScript.Echo strComputerDN 'Sanity Check

'Bind objGroup to LDAP entry for a AD group.
Set objGroup = GetObject("LDAP://cn=GroupName,ou=SubOUitsin,ou=OU its in,dc=YourDomain,dc=Domain,dc=ac,dc=uk")

'Check AD Group for computer member
if objGroup.IsMember(objComputer.AdsPath) = true then
WScript.Echo strComputerDN & " is a member of the AD Group."
else WScript.Echo strComputerDN & " is NOT a member of the AD Group."
end if

 

Try this, you will need to alter the group details to match yours.

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...