Returns the values found on the Group Policy page in Active Directory Users and Computers for the Sales OU
On Error Resume NextSet objContainer = GetObject _("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")strGpLink = objContainer.Get("gPLink")intGpOptions = objContainer.Get("gPOptions")If strGpLink <> " " ThenarrGpLinkItems = Split(strGpLink,"]")For i = UBound(arrGPLinkItems) to LBound(arrGpLinkItems) + 1 Step -1arrGPLink = Split(arrGpLinkItems(i-1),";")strDNGPLink = Mid(arrGPLink(0),9)WScript.Echo GetGPONameSelect Case arrGPLink(1)Case 0WScript.Echo "No Override is cleared and the GPO is enabled."Case 1WScript.Echo "No Override is cleared and the GPO is disabled."Case 2WScript.Echo "No Override is checked and the GPO is enabled."Case 3WScript.Echo "No Override is checked and the GPO is disabled."End SelectNextWScript.Echo VbCrLfEnd IfIf intGpOptions = 1 ThenWScript.Echo "Block Policy Inheritance is checked."ElseWScript.Echo "Block Policy Inheritance is not checked."End IfFunction GetGPONameSet objConnection = CreateObject("ADODB.Connection")objConnection.Open "Provider=ADsDSOObject;"Set objCommand = CreateObject("ADODB.Command")objCommand.ActiveConnection = objConnectionobjCommand.CommandText = _"<LDAP://cn=Policies,cn=System,dc=NA,dc=fabrikam,dc=com>;;" & _"distinguishedName,displayName;onelevel"Set objRecordSet = objCommand.ExecuteWhile Not objRecordSet.EOFIf objRecordSet.Fields("distinguishedName") = strDNGPLink ThenGetGPOName = objRecordSet.Fields("displayName")objConnection.CloseExit FunctionEnd IfobjRecordSet.MoveNextWendobjConnection.CloseEnd Function
This is a VB Script, this can be used by saving the file in .vbs file