Loading |
VBScript |
JavaScript |
Powershell |
Search Options: Assign a New Group Policy Link to an OUContent of Assign a New Group Policy Link to an OU.vbsMD5 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 :: |