By David Wiseman (Administrator)Created 23 Sep 2012
My Rating:
Not Rated

Remove Members from Group without attribute value

Language:  VBScript


Windows XP Unknown Windows 2003 Yes
Windows 2000 Unknown Windows NT Unknown
Vista Yes Windows 2008 Yes

Remove all members from group where the value of a particular attribute does not match a specified value.


Line Numbers: On  Off      Plain Text
OPTION Explicit
Dim strGroupDN,strNETBIOSDomain, strGroupName
Dim objSystemInfo, objGroup, objMember
Dim strAttributeName, strAttributeValue, strValue
Dim strMemberDN
' ********************* Setup *********************
' Group to remove users from
' Remove all users from group where the wWWHomePage value does not equal "20"
strAttributeName = "wWWHomePage"
strAttributeValue = "20"
' *************************************************
SET objSystemInfo = CREATEOBJECT("ADSystemInfo") 
'Required for name translate
strNETBIOSDomain = objSystemInfo.DomainShortName
' Convert group name to distinguished name
strGroupDN =  GetDN(strNETBIOSDomain,strGroupName)
SET objGroup = GETOBJECT("LDAP://" & strGroupDN)
FOR EACH objMember in objGroup.Members
		On Error Resume Next ' Ignore error that occurs when reading blank attribute value
		strValue = ""
		strValue = objMember.Get(strAttributeName)
		On Error GoTo 0
		' Remove user from group if attribute value does not match expected value
  		If strValue  <> strAttributeValue Then
  			WScript.Echo "Removing user " & objMember.ADsPath & " from group"
  			objGroup.Remove objMember.ADsPath
  		End If
' Function to convert name into distinguished name format
FUNCTION GetDN(BYVAL strDomain,strObject)
	' Use name translate to return the distinguished name
	' of a user from the NT UserName (sAMAccountName)
	' and the NETBIOS domain name.
	DIM objTrans
	SET objTrans = CREATEOBJECT("NameTranslate")
	objTrans.Init 1, strDomain
	objTrans.SET 3, strDomain & "\" & strObject
	GetDN = objTrans.GET(1) 
END Function


Got a useful script? Click here to upload!


  Post Comment
Order By:  
User Comments
Posted On: 9/29/2018 3:15:05 AM

If you are looking for Coach Outlet Online and want to pay a specific price, the best way to go for that is through Coach Factory Outlet Online.It's much cheaper to do it that way than to try to have a wallet for every Coach Factory Outlet Online you own. The secret to finding Coach Outlet Store for a discounted price is to shop online at an online shop that sales authentic Coach Factory Outlet. Coach Factory Outlet come in a variety of styles, colors and materials. If your dream is to own Coach Outlet Online, then make your dreams come true by going online and finding that handbag that you want. So,are you ready to find out just how you can get those Official Coach Factory Outlet Online? Depending on which Discount NFL Jerseys you happen to be wearing. NFL Jerseys China of the greatest players, hall-of-famers, Champion teams, and rookies are available to the public in authentic and replica styles. No matter if it's the current Cheap Authentic NFL Jerseys, an away Cheap NFL Jerseys From China or even a classic throwback that would make your grandfather proud it's become an American tradition to don your teams colors on Sunday afternoon if only to live vicariously through your favorite player if for just a few short hours. So now, when you see Wholesale NFL Jerseys being worn on Sunday afternoons, you will know that it is for more than just a fashion statement. We have Cheap NFL Jerseys that will fit your style. Get ready for the big game this season with some new Cheap Authentic NFL Jerseys. (More Source: Cheap Football Jerseys,Cheap Jerseys,Cheap Jerseys From China,Cheap Authentic Jerseys,Cheap Jerseys Online)

Posted On: 10/30/2018 4:34:54 AM

Attribute doesn't match a specified value. ip address

Posted On: 11/9/2018 1:27:55 AM

The league announced the news this morning, writing in a press release that,cheap authentic jerseys "Beginning Friday, November 9, NFL team 'outfits' will be available in the cheap nfl jerseys Shop. This unique opportunity will give Fortnite players the ability to purchase and customize up to eight outfits representing their favorite NFL teams."cheap jerseysWe're just getting started, though! There will also be "football-themed emotes, harvesting tools, gliders, and even a referee outfit." cheap sports jerseys Even a referee outfit! cheap jerseys from chinaSo there you have it, Fortniters (Fortnitees?). Your prayers have been answered. Everyone gets their favorite team's football jersey,wholesale jerseys and themed emotes, and harvesting tools, and gliders. Click here to choose the new cheap authentic jerseys from china and wholesale nfl jerseys! Receive comprehensive coverage of the Bears and stream the ‘Football Aftershow’ easily on your here cheap authentic nfl jerseys.It's not a giant surprise,custom cowboys jersey but it's still impressive to see. Fortnite is hugely popular among professional athletes, and it's football season,discount jerseys after all. Epic Games just announced an official partnership with the NFL to bring licensed jerseys to the popular battle royale game, letting players don the jerseys of their favorite teams as they blast each other into nfl jerseys cheap nfl jerseys cheap jerseys cheap jerseys from china wholesale jerseys cheap nfl jerseys from china china jerseys nfl jerseys china wholesale nfl jerseys cheap authentic nfl jerseys cheap jerseys online cheap authentic jerseys cheap sports jerseys cheap wholesale jerseys china wholesale jerseys discount nfl jerseys cheap authentic jerseys from china discount jerseys custom cowboys jersey Click here GOOGLE FACKBOOK Amazon nfl jerseys cheap cheap college football jerseys cheap nfl jerseys china cheap football jerseys custom jerseys cheap cheap nfl gear cheap nfl authentic jerseys cheap jerseys nfl nfl football jerseys cheap cheap nfl football jerseys cheap nfl jerseys free shipping cheap nfl nike jerseys custom nfl jerseys cheap nfl cheap jerseys