Toon posts:

[WIN2k3] / [Exch] MailQuantity

Pagina: 1
Acties:

Verwijderd

Topicstarter
Hallo,

Binnen ons netwerk heeft elke gebruiker een eigen mailbox met een grootte van ongeveer 2GB.
Er zijn enkele users die meer dan 2GB opslagruimte hebben. Is het mogelijk om een lijstje te genereren waarin staat hoeveel opslagruimte elke gebruiker heeft? Zoja, hoe?
Zelf heb ik al ontdekt dat ik een lijst kan exporteren van de users en de grootte van hun inbox. Hier staat echter niet bij hoeveel de gebruiker maximaal kan gebruiken etc.
Wij werken met WindowsServer2003 en Exchange 2003, met ongeveer 150 gebruikers.

Mvg.

  • Qwerty-273
  • Registratie: Oktober 2001
  • Nu online

Qwerty-273

Meukposter

***** ***

Zelf heb ik binnen onze afdeling een script geschreven/aangepast gebaseerd op het script wat hier wordt gegeven http://exchangepedia.com/...-quotas-including_17.html . Hiermee toon je de grote van alle mailboxen op je store en daarbij de quota's van de store - of de quota die op het account is gezet.

Erzsébet Bathory | Strajk Kobiet | You can lose hope in leaders, but never lose hope in the future.


Verwijderd

Topicstarter
Qwerty-273 schreef op woensdag 10 juni 2009 @ 10:39:
Zelf heb ik binnen onze afdeling een script geschreven/aangepast gebaseerd op het script wat hier wordt gegeven http://exchangepedia.com/...-quotas-including_17.html . Hiermee toon je de grote van alle mailboxen op je store en daarbij de quota's van de store - of de quota die op het account is gezet.
Bedankt voor je reactie, hier heb ik zeker iets aan gehad. Zoals je aangeeft zou het fijn zijn om ook de gebruikte grootte weer te geven. Zou je me jouw script kunnen doorsturen? IK heb zelf namelijk geen verstand van vbs.
indien dit niet via tweakers kan:
fcukunvrfindme@gmail.com (Don't Laugh, spam adres :P)

  • alt-92
  • Registratie: Maart 2000
  • Niet online

alt-92

ye olde farte

erhm..
Zullen we het dan gewoon via het forum afhandelen a.u.b.?

ik heb een 864 GB floppydrive! - certified prutser - the social skills of a thermonuclear device


Verwijderd

Topicstarter
alt-92 schreef op woensdag 10 juni 2009 @ 14:56:
erhm..
Zullen we het dan gewoon via het forum afhandelen a.u.b.?
Geen enkel probleem, maar is het mogelijk dan om een bestand te versturen via het forum? :?

  • Qwerty-273
  • Registratie: Oktober 2001
  • Nu online

Qwerty-273

Meukposter

***** ***

Beetje lastig om hier ons volledige script in te plakken - we maken namelijk nogal gebruik van custom AD velden waar het een en ander op gecheckt wordt etc. Ik heb er volgens mij een werkende snippet van gemaakt. Je zal natuurlijk nog wel even de juiste AD naam en mailboxservers in het script moeten invullen bij ServerList en domainContainer.

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Option Explicit
On Error Resume Next

Dim ServerList      ' List of computers to check
Dim server          ' Current computer to check
Dim fso1                ' File System Objects
Dim strWinMgmts         ' Connection string for WMI
Dim objWMIExchange      ' Exchange Namespace WMI object
Dim listExchange_Mailboxs   ' ExchangeLogons collection
Dim objExchange_Mailbox     ' A single ExchangeLogon WMI object
Dim logje       ' Output file
Dim domainContainer     ' 
Dim rootDSE
Dim conn        ' Conenction string/object
Dim LDAPStr     ' LDAP search for user string
Dim oPerson     ' User object
Dim rs          ' Record set for GC object equals Mbox displayname
Dim strmDBStorageQuota, strmDBOverQuotaLimit, strmDBOverHardQuotaLimit      'Mailbox quota values
Dim objStoreCommand     ' For retreiving mailbox store policy
Dim objStoreConnection      ' For retreiving mailbox store policy
Dim objStorePolicy      ' For retreiving mailbox store policy

Const cWMINameSpace = "root/MicrosoftExchangeV2"
Const cWMIInstance = "Exchange_Mailbox"
Const LOG_FILE = "log_user_mail.csv"        ' Output file

'--------------------------------------
' Set up the array of email servers
'--------------------------------------
ServerList = Array("MBX1","MBX2")

set fso1 = CreateObject("Scripting.FileSystemObject")
Set logje = fso1.CreateTextFile(LOG_FILE)
logje.WriteLine("""Lastname"",""Firstname"",""Mailaddress"",""Mailboxsize"",""Quota_store"",""Quota_warning"",""Quota_send"",""Quota_receive""")

domainContainer = "dc=ons,dc=domein,dc=com"
Set conn = CreateObject("ADODB.Connection")
conn.Provider = "ADSDSOObject"
conn.Open "ADs Provider"

Set objStoreConnection = CreateObject("ADODB.Connection")
objStoreConnection.Open "Provider=ADsDSOObject;"
Set objStoreCommand = CreateObject("ADODB.Command")
objStoreCommand.ActiveConnection = objStoreConnection  

' Create the object string, indicating WMI (winmgmts), using the
' current user credentials (impersonationLevel=impersonate),
' on the computer specified in the constant cComputerName, and
' using the CIM namespace for the Exchange provider.

'The rest of the script will fetch mailbox sizes for our mailbox servers. Mailbox sizes are in Kilobytes. 
'Then it will query the GC for user location
'Then query LDAP for user object - based on GC result of location
'Check if user uses default storage limit - if yes query mailbox store for limits - if not use ad values
'Write the user attributes to correct logfile

WScript.Echo "Starting now"

For Each server in ServerList
    WScript.Echo Now & " - Starting " & server & " search."
    'Connect by WMI to mailbox server
    strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//" & server & "/" & cWMINameSpace
    
    Set objWMIExchange =  GetObject(strWinMgmts)
    ' Verify we were able to correctly set the object.
    If Err.Number <> 0 Then
        WScript.Echo "ERROR: Unable to connect to the WMI namespace of " & server
        Err.Number = 0
    Else
        'The Resources that currently exist appear as a list of
        'Exchange_Mailbox instances in the Exchange namespace.
        Set listExchange_Mailboxs = objWMIExchange.InstancesOf(cWMIInstance)

        ' Were any Exchange_Mailbox Instances returned?
        If (listExchange_Mailboxs.count > 0) Then
            ' If yes, do the following:
            ' Iterate through the list of Exchange_Mailbox objects.
            For Each objExchange_Mailbox in listExchange_Mailboxs
                ' define GC search string based on mbox display name (is/should be unique within Alcatel forrest)
                LDAPStr = "<GC://" & DomainContainer & ">; (&(objectCategory=person)(objectClass=user)(displayname=" & objExchange_Mailbox.MailboxDisplayName & "));adspath;subtree"
                'Search in GC for adspath of user
                Set rs = conn.Execute(LDAPStr)
                'If only one result is found (should be the case for users)
                If rs.RecordCount = 1 Then
                    'Run a query against LDAP to get all user attributes
                    Set oPerson = GetObject(rs.Fields(0).Value)
                    
                    ' Find out the storage policy of the mailbox store incase the user doesn't use ad set limits ( extensionAttribute4 is filled with the nailstore of the user)
                    If oPerson.mDBUseDefaults = True Then
                        objStoreCommand.CommandText = "<LDAP://"& oPerson.homeMDB & ">;;mDBStorageQuota,mDBOverQuotaLimit,mDBOverHardQuotaLimit;subtree"
                        Set objStorePolicy = objStoreCommand.Execute 
                        If objStorePolicy.RecordCount = 1 Then
                            strmDBStorageQuota = objStorePolicy.Fields("mDBStorageQuota")
                            strmDBOverQuotaLimit = objStorePolicy.Fields("mDBOverQuotaLimit")
                            strmDBOverHardQuotaLimit = objStorePolicy.Fields("mDBOverHardQuotaLimit")
                        Else
                            strmDBStorageQuota = "not set"
                            strmDBOverQuotaLimit = "not set"
                            strmDBOverHardQuotaLimit = "not set"
                        End if                          
                    Else
                        strmDBStorageQuota = oPerson.mDBStorageQuota
                        strmDBOverQuotaLimit = oPerson.mDBOverQuotaLimit
                        strmDBOverHardQuotaLimit = oPerson.mDBOverHardQuotaLimit
                    End if
                    logje.WriteLine("""" & oPerson.sn & """,""" & oPerson.givenName & """,""" & oPerson.mail & """,""" & objExchange_Mailbox.Size & """,""" & oPerson.mDBUseDefaults & """,""" & strmDBStorageQuota & """,""" & strmDBOverQuotaLimit  & """,""" & strmDBOverHardQuotaLimit & """")
                End if
            Next
        Else
            ' If no Exchange_Mailbox instances were returned, display that.
            WScript.Echo "WARNING: No Exchange_Mailbox instances were returned for " & server
            Err.Number = 0
        End If
    End If
Next

Wscript.Echo Now & " - Completed"

Erzsébet Bathory | Strajk Kobiet | You can lose hope in leaders, but never lose hope in the future.


Verwijderd

Topicstarter
Qwerty-273 schreef op woensdag 10 juni 2009 @ 15:31:
Beetje lastig om hier ons volledige script in te plakken - we maken namelijk nogal gebruik van custom AD velden waar het een en ander op gecheckt wordt etc. Ik heb er volgens mij een werkende snippet van gemaakt. Je zal natuurlijk nog wel even de juiste AD naam en mailboxservers in het script moeten invullen bij ServerList en domainContainer.

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Option Explicit
On Error Resume Next

Dim ServerList      ' List of computers to check
Dim server          ' Current computer to check
Dim fso1                ' File System Objects
Dim strWinMgmts         ' Connection string for WMI
Dim objWMIExchange      ' Exchange Namespace WMI object
Dim listExchange_Mailboxs   ' ExchangeLogons collection
Dim objExchange_Mailbox     ' A single ExchangeLogon WMI object
Dim logje       ' Output file
Dim domainContainer     ' 
Dim rootDSE
Dim conn        ' Conenction string/object
Dim LDAPStr     ' LDAP search for user string
Dim oPerson     ' User object
Dim rs          ' Record set for GC object equals Mbox displayname
Dim strmDBStorageQuota, strmDBOverQuotaLimit, strmDBOverHardQuotaLimit      'Mailbox quota values
Dim objStoreCommand     ' For retreiving mailbox store policy
Dim objStoreConnection      ' For retreiving mailbox store policy
Dim objStorePolicy      ' For retreiving mailbox store policy

Const cWMINameSpace = "root/MicrosoftExchangeV2"
Const cWMIInstance = "Exchange_Mailbox"
Const LOG_FILE = "log_user_mail.csv"        ' Output file

'--------------------------------------
' Set up the array of email servers
'--------------------------------------
ServerList = Array("MBX1","MBX2")

set fso1 = CreateObject("Scripting.FileSystemObject")
Set logje = fso1.CreateTextFile(LOG_FILE)
logje.WriteLine("""Lastname"",""Firstname"",""Mailaddress"",""Mailboxsize"",""Quota_store"",""Quota_warning"",""Quota_send"",""Quota_receive""")

domainContainer = "dc=ons,dc=domein,dc=com"
Set conn = CreateObject("ADODB.Connection")
conn.Provider = "ADSDSOObject"
conn.Open "ADs Provider"

Set objStoreConnection = CreateObject("ADODB.Connection")
objStoreConnection.Open "Provider=ADsDSOObject;"
Set objStoreCommand = CreateObject("ADODB.Command")
objStoreCommand.ActiveConnection = objStoreConnection  

' Create the object string, indicating WMI (winmgmts), using the
' current user credentials (impersonationLevel=impersonate),
' on the computer specified in the constant cComputerName, and
' using the CIM namespace for the Exchange provider.

'The rest of the script will fetch mailbox sizes for our mailbox servers. Mailbox sizes are in Kilobytes. 
'Then it will query the GC for user location
'Then query LDAP for user object - based on GC result of location
'Check if user uses default storage limit - if yes query mailbox store for limits - if not use ad values
'Write the user attributes to correct logfile

WScript.Echo "Starting now"

For Each server in ServerList
    WScript.Echo Now & " - Starting " & server & " search."
    'Connect by WMI to mailbox server
    strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//" & server & "/" & cWMINameSpace
    
    Set objWMIExchange =  GetObject(strWinMgmts)
    ' Verify we were able to correctly set the object.
    If Err.Number <> 0 Then
        WScript.Echo "ERROR: Unable to connect to the WMI namespace of " & server
        Err.Number = 0
    Else
        'The Resources that currently exist appear as a list of
        'Exchange_Mailbox instances in the Exchange namespace.
        Set listExchange_Mailboxs = objWMIExchange.InstancesOf(cWMIInstance)

        ' Were any Exchange_Mailbox Instances returned?
        If (listExchange_Mailboxs.count > 0) Then
            ' If yes, do the following:
            ' Iterate through the list of Exchange_Mailbox objects.
            For Each objExchange_Mailbox in listExchange_Mailboxs
                ' define GC search string based on mbox display name (is/should be unique within Alcatel forrest)
                LDAPStr = "<GC://" & DomainContainer & ">; (&(objectCategory=person)(objectClass=user)(displayname=" & objExchange_Mailbox.MailboxDisplayName & "));adspath;subtree"
                'Search in GC for adspath of user
                Set rs = conn.Execute(LDAPStr)
                'If only one result is found (should be the case for users)
                If rs.RecordCount = 1 Then
                    'Run a query against LDAP to get all user attributes
                    Set oPerson = GetObject(rs.Fields(0).Value)
                    
                    ' Find out the storage policy of the mailbox store incase the user doesn't use ad set limits ( extensionAttribute4 is filled with the nailstore of the user)
                    If oPerson.mDBUseDefaults = True Then
                        objStoreCommand.CommandText = "<LDAP://"& oPerson.homeMDB & ">;;mDBStorageQuota,mDBOverQuotaLimit,mDBOverHardQuotaLimit;subtree"
                        Set objStorePolicy = objStoreCommand.Execute 
                        If objStorePolicy.RecordCount = 1 Then
                            strmDBStorageQuota = objStorePolicy.Fields("mDBStorageQuota")
                            strmDBOverQuotaLimit = objStorePolicy.Fields("mDBOverQuotaLimit")
                            strmDBOverHardQuotaLimit = objStorePolicy.Fields("mDBOverHardQuotaLimit")
                        Else
                            strmDBStorageQuota = "not set"
                            strmDBOverQuotaLimit = "not set"
                            strmDBOverHardQuotaLimit = "not set"
                        End if                          
                    Else
                        strmDBStorageQuota = oPerson.mDBStorageQuota
                        strmDBOverQuotaLimit = oPerson.mDBOverQuotaLimit
                        strmDBOverHardQuotaLimit = oPerson.mDBOverHardQuotaLimit
                    End if
                    logje.WriteLine("""" & oPerson.sn & """,""" & oPerson.givenName & """,""" & oPerson.mail & """,""" & objExchange_Mailbox.Size & """,""" & oPerson.mDBUseDefaults & """,""" & strmDBStorageQuota & """,""" & strmDBOverQuotaLimit  & """,""" & strmDBOverHardQuotaLimit & """")
                End if
            Next
        Else
            ' If no Exchange_Mailbox instances were returned, display that.
            WScript.Echo "WARNING: No Exchange_Mailbox instances were returned for " & server
            Err.Number = 0
        End If
    End If
Next

Wscript.Echo Now & " - Completed"
Bedankt!

  • alt-92
  • Registratie: Maart 2000
  • Niet online

alt-92

ye olde farte

Jzs 8)7 - daar hoef je die lap code niet voor te quoten hoor.

oh, mocht je trouwens een meer generieke functie voor je connection willen hebben:

Visual Basic:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Function FindUser(strUser)


    Const ADS_SCOPE_SUBTREE = 2

    Dim objConnection, objCommand, objRecordSet
    Dim strDN,strDefaultDomain 
        
    Set objRootDSE = GetObject("LDAP://RootDSE")
    strDefaultDomain = objRootDSE.Get("defaultNamingContext")
    Set objConnection = CreateObject("ADODB.Connection")
    Set objCommand =   CreateObject("ADODB.Command")
    objConnection.Provider = "ADsDSOObject"
    objConnection.Open "Active Directory Provider"
    Set objCommand.ActiveConnection = objConnection

    objCommand.Properties("Page Size") = 1000
    objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 

    objCommand.CommandText = _
        "SELECT distinguishedName FROM 'LDAP://" & strDefaultDomain  WHERE objectCategory='user' " & _
            "AND sAMAccountName='" & strUser & "'"

'msgBox objCommand.CommandText

    Set objRecordSet = objCommand.Execute

    if objRecordSet.EOF then
        FindUser = Empty
    else
        objRecordSet.MoveFirst
        Do Until objRecordSet.EOF
            FindUser = objRecordSet.Fields("distinguishedName").Value
                objRecordSet.MoveNext
        Loop
    end if

End Function


Door de objRootDSE.Get("defaultNamingContext") haal je onafhankelijk van de omgeving waar je de functie/script inzet altijd de domain in kwestie op.
Lekker generiek en portable dus :)

ik heb een 864 GB floppydrive! - certified prutser - the social skills of a thermonuclear device


Verwijderd

Topicstarter
alt-92, aangezien ik 0 verstand heb van vbs, zou je me misschien kunnen uitleggen wat het precies doet?

  • alt-92
  • Registratie: Maart 2000
  • Niet online

alt-92

ye olde farte

Dat zeg ik net? :)

Tenzij je een volledige cursus VBscripting 101 wil krijgen, maar ik denk dat je dan beter af bent met http://technet.microsoft.com/en-us/scriptcenter/default.aspx :)

Sowieso niet onverstandig, dan weet je tenminste wat je copy/paste scripts doen.
Dat weet jij ook niet van bovenstaande script van Qwerty-273 namelijk.

ik heb een 864 GB floppydrive! - certified prutser - the social skills of a thermonuclear device


Verwijderd

Topicstarter
Qwerty-273 schreef op woensdag 10 juni 2009 @ 15:31:
Beetje lastig om hier ons volledige script in te plakken - we maken namelijk nogal gebruik van custom AD velden waar het een en ander op gecheckt wordt etc. Ik heb er volgens mij een werkende snippet van gemaakt. Je zal natuurlijk nog wel even de juiste AD naam en mailboxservers in het script moeten invullen bij ServerList en domainContainer.

code:
1
2
3
4
5
Option Explicit
On Error Resume Next..


...Wscript.Echo Now & " - Completed"
Inmiddels een testserver opgezet met exchange etc. alles werkt en ik dacht, laat ik dat script even testen...

Waar moet ik de mailboxserver invullen? ik neem aan:
"ServerList = Array("MBX1","MBX2")"?

hoe ziet deze er uit?

mijn netwerkje heet: EEtest.local
waarbij eigelijk elke instelling standaard is.
Pagina: 1