Break ON
$=SetOption("WrapAtEOL","ON")
$TRUE=Not 0
$FALSE=Not $TRUE
If Not IsDeclared($SERVER)
"You must supply a server name on the command line"+@CRLF
" kix32.exe script.kix $$SERVER=server"+@CRLF
Exit 1
EndIf
$PR_HAS_RULES = &663A000B
$PR_URL_NAME = &6707001E
$PR_CREATOR = &3FF8001E
$sIni="c:\forwardingRules.ini"
;wfile.writeline("Mailbox,FolderPath,Creator,AdressObject,SMTPForwdingAddress")
$conn=CreateObject("ADODB.Connection")
$com=CreateObject("ADODB.Command")
$iAdRootDSE=GetObject("LDAP://RootDSE")
$strNamingContext=$iAdRootDSE.Get("configurationNamingContext")
$strDefaultNamingContext=$iAdRootDSE.Get("defaultNamingContext")
$Conn.Provider="ADsDSOObject"
$Conn.Open("ADs Provider")
$svcQuery="<LDAP://"+$strNamingContext+">;(&(objectCategory=msExchExchangeServer)(cn="+$SERVER+"));cn,name,legacyExchangeDN;subtree"
$Com.ActiveConnection=$Conn
$Com.CommandText=$svcQuery
$Rs=$Com.Execute
While Not $Rs.eof
$GALQueryFilter="(&(&(&(& (mailnickname=*)(!msExchHideFromAddressLists=TRUE)(| (&(objectCategory=person)(objectClass=user)(msExchHomeServerName="+$rs.fields("legacyExchangeDN")+")) )))))"
$strQuery="<LDAP://"+$strDefaultNamingContext+">;"+$GALQueryFilter+";distinguishedName,mailnickname;subtree"
$com.Properties("Page Size").Value = 100
$Com.CommandText=$strQuery
$Rs1 = $Com.Execute
While Not $Rs1.eof
"Processing: "+$rs1.fields("mailnickname")+@CRLF
procmailboxes($SERVER,$rs1.fields("mailnickname"))
$rs1.movenext
Loop
$rs.movenext
Loop
$rs.close
$fso = 0
$conn = 0
$com = 0
"Done"+@CRLF
Exit 0
Function procmailboxes($sServer,$sMailName)
"In ProcMailBoxes"+@CRLF
EndFunction