Loading
Scriptbox
 VBScript Links 
 About VBscript 
 JavaScript Links 
 About JavaScript 
 Powershell Links 
 PSCRIPT the Script Launcher 
 PowerShell Shortcut Keys 
 About Powershell 
     VBScript
    JavaScript
    Powershell
Disclaimer
Contact
Latest 10 Scripts
Script search
  :: { Category } :: 0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ
         

Search Options:  Assign  a  New  Group  Policy  Link  to  an  OU  

 Content of Assign a New Group Policy Link to an OU.vbs
MD5 Hash: E6C9AEC94C1D93DEED74A70A6308C730
' Description: Assigns the Group Policy link Sales Policy to the Sales OU in Active Directory.


On Error Resume Next

Set objContainer = GetObject _
("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

strExistingGPLink = objContainer.Get("gPLink")

strGPODisplayName = "Sales Policy"
strGPOLinkOptions = 2
strNewGPLink = "[" & GetGPOADsPath & ";" & strGPOLinkOptions & "]"

objContainer.Put "gPLink", strExistingGPLink & strNewGPLink
objContainer.Put "gPOptions", "0"

objContainer.SetInfo

Function GetGPOADsPath
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

objCommand.CommandText = _
";;" & _
"distinguishedName,displayName;onelevel"
Set objRecordSet = objCommand.Execute

Do Until objRecordSet.EOF
If objRecordSet.Fields("displayName") = strGPODisplayName Then
GetGPOADsPath = "LDAP://" & objRecordSet.Fields("distinguishedName")
objConnection.Close
Exit Function
End If
objRecordSet.MoveNext
Loop
objConnection.Close
End Function

   © 2008 - 2013 Boris Toll      :: Scripts available: 6.481 ::      :: scriptbox.toll.at ::      :: powered by www.toll.at ::
  Google Entries:n/a
  Yahoo Backlinks:n/a
  Live Backlinks:n/a
  del.icio.us Bookmarks:n/a
  Technorati Links:n/a