NOTESSIDAN

Allt om Lotus Notes & Domino




Easy way to change mail quota on several servers at once
Quotas is not replicated so if you have the same mailfiles on serveral servers the administrator need to change the quota on all servers. This script is an easy way to update all mailfiles on all servers at once.
Image below show a custom view we made in the Domino Directory to easily change the quota




- The script below is a sample for changing three servers at the same time, modify the code to add more or less servers
- Use this script in an action in a people view in Domino Directory
- Script process all selected people in the view
- Script will update the person records with the current quota in a field "ModQuota", add a new column to your view if you want to show this field in the view




Sub Initialize

On Error GoTo e
Dim session As New NotesSession, db As NotesDatabase, dc As NotesDocumentCollection
Dim i As Integer, doc As NotesDocument, maildb As NotesDatabase, mailfile As String
Dim srv1 As String, srv2 As String, srv3 As String, update As Integer
Set db = session.currentdatabase

srv1 = "server1"
srv2 = "server2"
srv3 = "server3"

Dim quota As String, warning As String
Set dc = db.UnprocessedDocuments

quota = InputBox("Enter Quota","Enter Quota in Mb to set on " + CStr(dc.count) + " selected user","500")
If Not IsNumeric(quota) Then MsgBox "Not a valid number, exiting",64,"Info":Exit Sub
warning = InputBox("Enter Quota Warning","Enter Quota Warning in Mb to set on " + CStr(dc.count) + " selected user in","450")
If Not IsNumeric(warning) Then MsgBox "Not a valid number, exiting",64,"Info":Exit Sub

If dc Is Nothing Then Print "Nothing to do, exiting ":Exit Sub
If MsgBox("Are you sure you want to set quota " + quota + "Mb and Warning " + warning + " Mb" + " on " + CStr(dc.count) + " Users?",68,"Question") <> 6 Then Exit Sub

For i = 1 To dc.count
Set doc = dc.getnthdocument(i)
mailfile = doc.MailFile(0)

Set maildb = session.GetDatabase(srv1,mailfile,False)
If Not maildb Is Nothing Then
If quota = "0" Then
maildb.SizeQuota = 0
maildb.SizeWarning = 0
Print "Quota set for mail file " + mailfile + " on " + srv1
Else
maildb.SizeQuota = CLng(quota) * 1024
maildb.SizeWarning = CLng(warning) * 1024
Print "Quota set for mail file " + mailfile + " on " + srv1
End If
update = 1
Else
Print "Could not open " + mailfile + " on " + srv1
End If
Print "Quota on server " + srv1 + " is now " + CStr(maildb.SizeQuota) + " warning is " + CStr(maildb.SizeWarning)

Set maildb = session.GetDatabase(srv2,mailfile,False)
If Not maildb Is Nothing Then
If quota = "0" Then
maildb.SizeQuota = 0
maildb.SizeWarning = 0
Print "Quota set for mail file " + mailfile + " on " + srv2
Else
maildb.SizeQuota = CLng(quota) * 1024
maildb.SizeWarning = CLng(warning) * 1024
Print "Quota set for mail file " + mailfile + " on " + srv2
End If
update = 1
Else
Print "Could not open " + mailfile + " on " + srv2
End If
Print "Quota on server " + srv2 + " is now " + CStr(maildb.SizeQuota) + " warning is " + CStr(maildb.SizeWarning)

Set maildb = session.GetDatabase(srv3,mailfile,False)
If Not maildb Is Nothing Then
If quota = "0" Then
maildb.SizeQuota = 0
maildb.SizeWarning = 0
Print "Quota set for mail file " + mailfile + " on " + srv3
Else
maildb.SizeQuota = CLng(quota) * 1024
maildb.SizeWarning = CLng(warning) * 1024
Print "Quota set for mail file " + mailfile + " on " + srv3
End If

update = 1
Else
Print "Could not open " + mailfile + " on " + srv3
End If
Print "Quota on server " + srv3 + " is now " + CStr(maildb.SizeQuota) + " warning is " + CStr(maildb.SizeWarning)

If update = 1 Then
doc.ModQuota = quota
Call doc.save(False,False)
End If
update = 0
Next
MsgBox "Ready, check statusbar"

Exit Sub
e:
Print Error,Erl
End Sub


The script below will show a prompt with the selected users active quota and update the person record with correct quota in the ModQuota field

- This script is a sample for displaying quota information from three servers at the same time, modify the code to add more or less servers
- Use this script in an action in a people view in Domino Directory
- Script will update the person records with the current quota in a field "ModQuota", add a new column to your view if you want to show this field in the view
- Script will currently only show quota from the first server, (need to fix this someday :-)


Sub Initialize


On Error Resume Next
Dim session As New NotesSession, db As NotesDatabase, dc As NotesDocumentCollection
Dim i As Integer, doc As NotesDocument, maildb As NotesDatabase, mailfile As String
Dim srv1 As String, srv2 As String, srv3 As String, update As Integer
Set db = session.currentdatabase
Print "Start"
srv1 = "server1"
srv2 = "server2"
srv3 = "server3"

Dim q As String
Dim quota As Long
Set dc = db.UnprocessedDocuments
For i = 1 To dc.count

Set doc = dc.getnthdocument(i)

quota = 0
mailfile = doc.MailFile(0)

Set maildb = session.GetDatabase(srv1,mailfile, False)
If Not maildb Is Nothing Then
quota = maildb.SizeQuota / 1024
q = "quota on " + srv1 + ": " + CStr(maildb.SizeQuota / 1024) + Chr$(10)
Else
'quota = -1
q = "Could not open " + mailfile + " on " + srv1+ Chr$(10)
End If


Set maildb = session.GetDatabase(srv2,mailfile, False)
If Not maildb Is Nothing Then
If maildb.SizeQuota > quota Then quota = maildb.SizeQuota / 1024
q = q + "quota on " + srv2 + ": " + CStr(maildb.SizeQuota / 1024)+ Chr$(10)
Else
q = q + "Could not open " + mailfile + " on " + srv2+ Chr$(10)
'quota = -1
End If

Set maildb = session.GetDatabase(srv3,mailfile,False)
If Not maildb Is Nothing Then
If maildb.SizeQuota > quota Then quota = maildb.SizeQuota / 1024
q = q + "quota on " + srv3 + ": " + CStr(maildb.SizeQuota / 1024)+ Chr$(10)
Else
q = q + "Could not open " + mailfile + " on " + srv3+ Chr$(10)
'quota = -1
End If



Print "Quota = " + CStr(quota)
doc.ModQuota = quota
Call doc.save(False,False)
Print "Saved user " + doc.FirstName(0) + " " + doc.LastName(0)

MsgBox q,64,"Info"


Next
Print "End"

Exit Sub
e:

Print Error,Erl



End Sub



Relevanta Poster på Notessidan:



Fler Poster om:

Fler bloggar om:

Technorati:

Delicious:
Publicerad 2014-05-22 | Kommentarer: 1 | Läsningar:

Kommentarer

Jared Jones ( 2014-07-09 23:37:02 )



Sök på Notessidan
Thomas Adrian
ThomasCertifierad utvecklare och administratör inom Notes & Domino

Kontakta mig







Senaste Sökningarna på Notessidan
Sön - sharepoint (R:1)
Sön - räkna and antal and besökare (R:0)
Sön - browser (R:17)
Sön - stoppar and mail (R:1)
Sön - korrupt (R:3)
Sön - böcker (R:0)
Sön - kalendern (R:12)
Sön - feature (R:15)
Sön - print and mime (R:2)
Sön - länka (R:0)
Sön - databasen (R:94)
Sön - access (R:47)
Sön - outlook (R:15)
Sön - webanvändare (R:0)
Sön - google and maps (R:6)
Sön - juffe (R:2)
Sön - uidoc.print (R:1)
Sön - java and lotusscript (R:26)
Sön - besök (R:0)




Databasstatistik Blogg
Uppdateras var 15:e Minut

Antal Poster:562
Antal Kommentarer: 1378
Alla sidvisningar idag:
Unika Besökare idag:
Databasstorlek: 178,5Mb
Fixup: 2019-07-15 00:31:17
FT:2019-07-16 03:10:24
DB Procent använd: 99,5
Antal Agenter: 42
Antal Formulär: 65
Antal Vyer: 60
Antal Dokument: 7927
Antal Image Resources: 108
Antal Subformulär: 18
Antal Scriptbibliotek: 11
Totalt Antal Designelement: 576
Antal Attachments: 159
Antal Konflikter: 0
Server version 1: 405
Server version 2: Release 9.0.1FP9|August 14, 2017
Server Plattform: Windows/64
Ändrad: 2019-07-16 04:40:25
Server Tidszon: Z=-1$DO=1$DL=3 -1 1 10 -1 1$ZX=131$ZN=W. Europe
Region:
Kommentarsspam Idag: 3
Kommentarsspam Totalt: 17897


BlogRankers.com

Top Sites at iWEBTOOL.com

Fight Spam! Click Here!

Bloggtoppen.se

Listed on BlogShares

Increase website traffic

Top Internet Blogs

Site Checker