Microsoft Exchange üzerinde email kota ayarı scripti


Microsoft Exchange üzerinde email kota ayarı scripti

on error resume next

CONST QUOTA_EXEMPTION = 500000 ‘* > mDBOverHardQuotaLimit is exempted to use default quota
CONST EXEMPTED_WORD = “exempted”

Const ADS_SCOPE_SUBTREE = 2
Const ADS_CHASE_REFERRALS_EXTERNAL = &h40
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
Const ADS_UF_PASSWD_CANT_CHANGE = &h00040
Const ADS_UF_PASSWORD_EXPIRED = &H80000
Const ADS_UF_LOCKOUT = &h00010

Set rootDSE = GetObject(”LDAP://RootDSE”)
sObjectDN = “LDAP://” & rootDSE.Get(”defaultNamingContext”)
Set rootDSE = Nothing
Set oIADs = GetObject(sObjectDN)
set con=createobject(”ADODB.Connection”)
set com =createobject(”ADODB.Command”)
Set WshShell = Wscript.CreateObject(”Wscript.Shell”)
Set objFSO = CreateObject(”Scripting.FileSystemObject”)

con.Provider = “ADsDSOObject”
con.Open “Active Directory Provider”

Set Com.ActiveConnection = con

sMsg = “select AdsPath,CN,Name,samAccountName from ‘” & oIADs.ADsPath
sMsg = sMsg & “‘ where objectCategory=’user’ order by Name”

Com.CommandText = sMsg
Com.Properties(”searchscope”) = ADS_SCOPE_SUBTREE
Com.Properties(”Chase referrals”) = ADS_CHASE_REFERRALS_EXTERNAL
Com.Properties(”Cache Results”) = False

Set rs = Com.Execute
i = 0

While Not rs.EOF
‘ wscript.echo rs.Fields(”fieldname”)
DoWorkOnUser rs.Fields(”AdsPath”)
i = i + 1
rs.MoveNext
Wend

rs.Close

Sub DoWorkOnUser(strUser)

Set objUser = GetObject(strUser)
Err.Clear

If len(objUser.DisplayName)=0 Then
wscript.echo objUser.Name & ” – No Access !!!!!!!!!!”
Else
if objUser.MDBUseDefaults = “False” then
Wscript.echo “—-”
Wscript.echo “DisplayName – ” & objUser.DisplayName
Wscript.echo “mDBOverHardQuotaLimit – ” & objUser.mDBOverHardQuotaLimit
Wscript.echo “mDBOverQuotaLimit – ” & objUser.mDBOverQuotaLimit
Wscript.echo “mDBStorageQuota – ” & objUser.mDBStorageQuota
Wscript.echo “mDBUseDefaults – ” & objUser.mDBUseDefaults
lsResult = objUser.mDBUseDefaults
If objUser.mDBOverHardQuotaLimit >= QUOTA_EXEMPTION Then
Wscript.echo “EXEMPTED: ” & objUser.mDBOverHardQuotaLimit & ” is over default quota ” & QUOTA_EXEMPTION & “.”
lsResult = lsResult & EXEMPTED_WORD
End If
‘SET THE QUOTAS TO DEFAULT!
SetMbxQuotas strUser
Wscript.echo “—-”
end if
End If
Set objUser = nothing
‘ RetrieveUserSettings = lsResult

End sub

‘* ——————————————————
‘* Function: Set User Settings
‘* ——————————————————
Sub SetMbxQuotas (strUser)

wscript.echo “Setting mDBUseDefaults to True.”
Set SetUser = GetObject(strUser)
SetUser.Put “mDBUseDefaults”, True
SetUser.Put “mDBOverHardQuotaLimit”, 0
SetUser.Put “mDBOverQuotaLimit”, 0
SetUser.Put “mDBStorageQuota”, 0
SetUser.SetInfo
If err.number > 0 Then
wscript.echo “Error setting account attribute: ” & lsAttribute
err.Clear
on error goto 0
Else
wscript.echo “Set to True successfully.”
End If
Set SetUser = nothing

End Sub

wscript.quit

Etiketler:, ,

Bir Cevap Yazın

Aşağıya bilgilerinizi girin veya oturum açmak için bir simgeye tıklayın:

WordPress.com Logosu

WordPress.com hesabınızı kullanarak yorum yapıyorsunuz. Log Out / Değiştir )

Twitter resmi

Twitter hesabınızı kullanarak yorum yapıyorsunuz. Log Out / Değiştir )

Facebook fotoğrafı

Facebook hesabınızı kullanarak yorum yapıyorsunuz. Log Out / Değiştir )

Google+ fotoğrafı

Google+ hesabınızı kullanarak yorum yapıyorsunuz. Log Out / Değiştir )

Connecting to %s

%d blogcu bunu beğendi: