bsharath
asked on
Get the Mailboxes as per the storage to a file
Hi,
Is there a way to get the mailboxes names and other details as per the storage to a csv or txt file.
regards
Sharath
Is there a way to get the mailboxes names and other details as per the storage to a csv or txt file.
regards
Sharath
ASKER
I get this.
-------------------------- -
Windows Script Host
-------------------------- -
Script: C:\Getechangestorsge.vbs
Line: 33
Char: 18
Error: Invalid 'for' loop control variable
Code: 800A0410
Source: Microsoft VBScript compilation error
-------------------------- -
OK
-------------------------- -
--------------------------
Windows Script Host
--------------------------
Script: C:\Getechangestorsge.vbs
Line: 33
Char: 18
Error: Invalid 'for' loop control variable
Code: 800A0410
Source: Microsoft VBScript compilation error
--------------------------
OK
--------------------------
oops
Const strtextfile = "C:\results.csv"
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper sonate}!\\ " & strComputer & _
"\ROOT\MicrosoftExchangeV2 ")
Set colItems = objWMIService.ExecQuery _
("Select * from Exchange_Mailbox")
Set oFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set oOutput = oFSO.OpenTextFile(strtextf ile,8,True )
Header = "Associated content count" & vbtab & _
"Date discovered absent in directory service: " & vbtab & _
"Delete messages size extended " & vbtab & _
"Last logged-on user account " & vbtab & _
"Last logoff time" & vbtab & _
"Last logon time" & vbtab & _
"Legacy distinguished name" & vbtab & _
"Mailbox display name" & vbtab & _
"Mailbox GUID" & vbtab & _
"Server name" & vbtab & _
"Size" & vbtab & _
"Storage group name" & vbtab & _
"Storage limit information" & vbtab & _
"Store name" & vbtab & _
"Total items" & vbcrlf
oOutput.Write(header)
For Each objItem in colItems
results = results & changenull(objItem.AssocCo ntentCount ) & vbtab
results = results & changenull(objItem.DateDis coveredAbs entInDS) & vbtab
results = results & changenull(objItem.Deleted MessageSiz eExtended) & vbtab
results = results & changenull(objItem.LastLog gedOnUserA ccount) & vbtab
results = results & changenull(objItem.LastLog offTime) & vbtab
results = results & changenull(objItem.LastLog onTime) & vbtab
results = results & changenull(objItem.LegacyD N) & vbtab
results = results & changenull(objItem.Mailbox DisplayNam e) & vbtab
results = results & changenull(objItem.Mailbox GUID) & vbtab
results = results & changenull(objItem.ServerN ame) & vbtab
results = results & changenull(objItem.Size) & vbtab
results = results & changenull(objItem.Storage GroupName) & vbtab
results = results & changenull(objItem.Storage LimitInfo) & vbtab
results = results & changenull(objItem.StoreNa me) & vbtab
results = results & changenull(objItem.TotalIt ems) & vbcrlf
oOutput.Write(Results)
Next
function changenull(item)
'incase things are null
if item = vbempty or item = "" then
item = "NULL"
End Function
Const strtextfile = "C:\results.csv"
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
"\ROOT\MicrosoftExchangeV2
Set colItems = objWMIService.ExecQuery _
("Select * from Exchange_Mailbox")
Set oFSO = CreateObject("Scripting.Fi
Set oOutput = oFSO.OpenTextFile(strtextf
Header = "Associated content count" & vbtab & _
"Date discovered absent in directory service: " & vbtab & _
"Delete messages size extended " & vbtab & _
"Last logged-on user account " & vbtab & _
"Last logoff time" & vbtab & _
"Last logon time" & vbtab & _
"Legacy distinguished name" & vbtab & _
"Mailbox display name" & vbtab & _
"Mailbox GUID" & vbtab & _
"Server name" & vbtab & _
"Size" & vbtab & _
"Storage group name" & vbtab & _
"Storage limit information" & vbtab & _
"Store name" & vbtab & _
"Total items" & vbcrlf
oOutput.Write(header)
For Each objItem in colItems
results = results & changenull(objItem.AssocCo
results = results & changenull(objItem.DateDis
results = results & changenull(objItem.Deleted
results = results & changenull(objItem.LastLog
results = results & changenull(objItem.LastLog
results = results & changenull(objItem.LastLog
results = results & changenull(objItem.LegacyD
results = results & changenull(objItem.Mailbox
results = results & changenull(objItem.Mailbox
results = results & changenull(objItem.ServerN
results = results & changenull(objItem.Size) & vbtab
results = results & changenull(objItem.Storage
results = results & changenull(objItem.Storage
results = results & changenull(objItem.StoreNa
results = results & changenull(objItem.TotalIt
oOutput.Write(Results)
Next
function changenull(item)
'incase things are null
if item = vbempty or item = "" then
item = "NULL"
End Function
strComputer = "."
if you're not running this on your exchange box, then
strComputer = "exchangeserver" << where exchangeserver is tha name of your exchange server
if you're not running this on your exchange box, then
strComputer = "exchangeserver" << where exchangeserver is tha name of your exchange server
You can right click on each mail store and export to a CSV file
ASKER
weellio
After specifying the exchange name also i get this.
-------------------------- -
Windows Script Host
-------------------------- -
Script: C:\Getechangestorsge.vbs
Line: 33
Char: 18
Error: Invalid 'for' loop control variable
Code: 800A0410
Source: Microsoft VBScript compilation error
-------------------------- -
OK
-------------------------- -
After specifying the exchange name also i get this.
--------------------------
Windows Script Host
--------------------------
Script: C:\Getechangestorsge.vbs
Line: 33
Char: 18
Error: Invalid 'for' loop control variable
Code: 800A0410
Source: Microsoft VBScript compilation error
--------------------------
OK
--------------------------
ASKER
Any help...
ASKER
Any help...
mboppe:
You can right click on each mail store and export to a CSV file
did you try that?
Const strtextfile = "C:\results.csv"
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper sonate}!\\ " & strComputer & _
"\ROOT\MicrosoftExchangeV2 ")
Set colItems = objWMIService.ExecQuery _
("Select * from Exchange_Mailbox")
if err.number <> 0 then
wscript.echo err.number & " : " & err.description & " : problem connection to" & strComputer
err.clear
Set oFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set oOutput = oFSO.OpenTextFile(strtextf ile,8,True )
Header = "Associated content count" & vbtab & _
"Date discovered absent in directory service: " & vbtab & _
"Delete messages size extended " & vbtab & _
"Last logged-on user account " & vbtab & _
"Last logoff time" & vbtab & _
"Last logon time" & vbtab & _
"Legacy distinguished name" & vbtab & _
"Mailbox display name" & vbtab & _
"Mailbox GUID" & vbtab & _
"Server name" & vbtab & _
"Size" & vbtab & _
"Storage group name" & vbtab & _
"Storage limit information" & vbtab & _
"Store name" & vbtab & _
"Total items" & vbcrlf
oOutput.Write(header)
For Each objItem in colItems
results = results & changenull(objItem.AssocCo ntentCount ) & vbtab
results = results & changenull(objItem.DateDis coveredAbs entInDS) & vbtab
results = results & changenull(objItem.Deleted MessageSiz eExtended) & vbtab
results = results & changenull(objItem.LastLog gedOnUserA ccount) & vbtab
results = results & changenull(objItem.LastLog offTime) & vbtab
results = results & changenull(objItem.LastLog onTime) & vbtab
results = results & changenull(objItem.LegacyD N) & vbtab
results = results & changenull(objItem.Mailbox DisplayNam e) & vbtab
results = results & changenull(objItem.Mailbox GUID) & vbtab
results = results & changenull(objItem.ServerN ame) & vbtab
results = results & changenull(objItem.Size) & vbtab
results = results & changenull(objItem.Storage GroupName) & vbtab
results = results & changenull(objItem.Storage LimitInfo) & vbtab
results = results & changenull(objItem.StoreNa me) & vbtab
results = results & changenull(objItem.TotalIt ems) & vbcrlf
oOutput.Write(Results)
Next
function changenull(item)
'incase things are null
if item = vbempty or item = "" then
item = "NULL"
End Function
back to top
You can right click on each mail store and export to a CSV file
did you try that?
Const strtextfile = "C:\results.csv"
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
"\ROOT\MicrosoftExchangeV2
Set colItems = objWMIService.ExecQuery _
("Select * from Exchange_Mailbox")
if err.number <> 0 then
wscript.echo err.number & " : " & err.description & " : problem connection to" & strComputer
err.clear
Set oFSO = CreateObject("Scripting.Fi
Set oOutput = oFSO.OpenTextFile(strtextf
Header = "Associated content count" & vbtab & _
"Date discovered absent in directory service: " & vbtab & _
"Delete messages size extended " & vbtab & _
"Last logged-on user account " & vbtab & _
"Last logoff time" & vbtab & _
"Last logon time" & vbtab & _
"Legacy distinguished name" & vbtab & _
"Mailbox display name" & vbtab & _
"Mailbox GUID" & vbtab & _
"Server name" & vbtab & _
"Size" & vbtab & _
"Storage group name" & vbtab & _
"Storage limit information" & vbtab & _
"Store name" & vbtab & _
"Total items" & vbcrlf
oOutput.Write(header)
For Each objItem in colItems
results = results & changenull(objItem.AssocCo
results = results & changenull(objItem.DateDis
results = results & changenull(objItem.Deleted
results = results & changenull(objItem.LastLog
results = results & changenull(objItem.LastLog
results = results & changenull(objItem.LastLog
results = results & changenull(objItem.LegacyD
results = results & changenull(objItem.Mailbox
results = results & changenull(objItem.Mailbox
results = results & changenull(objItem.ServerN
results = results & changenull(objItem.Size) & vbtab
results = results & changenull(objItem.Storage
results = results & changenull(objItem.Storage
results = results & changenull(objItem.StoreNa
results = results & changenull(objItem.TotalIt
oOutput.Write(Results)
Next
function changenull(item)
'incase things are null
if item = vbempty or item = "" then
item = "NULL"
End Function
back to top
ASKER
I get this.
-------------------------- -
Windows Script Host
-------------------------- -
Script: C:\Mailbox.vbs
Line: 56
Char: 5
Error: Expected 'If'
Code: 800A03F4
Source: Microsoft VBScript compilation error
-------------------------- -
OK
-------------------------- -
--------------------------
Windows Script Host
--------------------------
Script: C:\Mailbox.vbs
Line: 56
Char: 5
Error: Expected 'If'
Code: 800A03F4
Source: Microsoft VBScript compilation error
--------------------------
OK
--------------------------
Const strtextfile = "C:\results.csv"
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper sonate}!\\ " & strComputer & _
"\ROOT\MicrosoftExchangeV2 ")
Set colItems = objWMIService.ExecQuery _
("Select * from Exchange_Mailbox")
if err.number <> 0 then
wscript.echo err.number & " : " & err.description & " : problem connection to" & strComputer
err.clear
Set oFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set oOutput = oFSO.OpenTextFile(strtextf ile,8,True )
Header = "Associated content count" & vbtab & _
"Date discovered absent in directory service: " & vbtab & _
"Delete messages size extended " & vbtab & _
"Last logged-on user account " & vbtab & _
"Last logoff time" & vbtab & _
"Last logon time" & vbtab & _
"Legacy distinguished name" & vbtab & _
"Mailbox display name" & vbtab & _
"Mailbox GUID" & vbtab & _
"Server name" & vbtab & _
"Size" & vbtab & _
"Storage group name" & vbtab & _
"Storage limit information" & vbtab & _
"Store name" & vbtab & _
"Total items" & vbcrlf
oOutput.Write(header)
For Each objItem in colItems
results = results & changenull(objItem.AssocCo ntentCount ) & vbtab
results = results & changenull(objItem.DateDis coveredAbs entInDS) & vbtab
results = results & changenull(objItem.Deleted MessageSiz eExtended) & vbtab
results = results & changenull(objItem.LastLog gedOnUserA ccount) & vbtab
results = results & changenull(objItem.LastLog offTime) & vbtab
results = results & changenull(objItem.LastLog onTime) & vbtab
results = results & changenull(objItem.LegacyD N) & vbtab
results = results & changenull(objItem.Mailbox DisplayNam e) & vbtab
results = results & changenull(objItem.Mailbox GUID) & vbtab
results = results & changenull(objItem.ServerN ame) & vbtab
results = results & changenull(objItem.Size) & vbtab
results = results & changenull(objItem.Storage GroupName) & vbtab
results = results & changenull(objItem.Storage LimitInfo) & vbtab
results = results & changenull(objItem.StoreNa me) & vbtab
results = results & changenull(objItem.TotalIt ems) & vbcrlf
oOutput.Write(Results)
Next
function changenull(item)
'incase things are null
if item = vbempty or item = "" then
item = "NULL"
end if
End Function
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
"\ROOT\MicrosoftExchangeV2
Set colItems = objWMIService.ExecQuery _
("Select * from Exchange_Mailbox")
if err.number <> 0 then
wscript.echo err.number & " : " & err.description & " : problem connection to" & strComputer
err.clear
Set oFSO = CreateObject("Scripting.Fi
Set oOutput = oFSO.OpenTextFile(strtextf
Header = "Associated content count" & vbtab & _
"Date discovered absent in directory service: " & vbtab & _
"Delete messages size extended " & vbtab & _
"Last logged-on user account " & vbtab & _
"Last logoff time" & vbtab & _
"Last logon time" & vbtab & _
"Legacy distinguished name" & vbtab & _
"Mailbox display name" & vbtab & _
"Mailbox GUID" & vbtab & _
"Server name" & vbtab & _
"Size" & vbtab & _
"Storage group name" & vbtab & _
"Storage limit information" & vbtab & _
"Store name" & vbtab & _
"Total items" & vbcrlf
oOutput.Write(header)
For Each objItem in colItems
results = results & changenull(objItem.AssocCo
results = results & changenull(objItem.DateDis
results = results & changenull(objItem.Deleted
results = results & changenull(objItem.LastLog
results = results & changenull(objItem.LastLog
results = results & changenull(objItem.LastLog
results = results & changenull(objItem.LegacyD
results = results & changenull(objItem.Mailbox
results = results & changenull(objItem.Mailbox
results = results & changenull(objItem.ServerN
results = results & changenull(objItem.Size) & vbtab
results = results & changenull(objItem.Storage
results = results & changenull(objItem.Storage
results = results & changenull(objItem.StoreNa
results = results & changenull(objItem.TotalIt
oOutput.Write(Results)
Next
function changenull(item)
'incase things are null
if item = vbempty or item = "" then
item = "NULL"
end if
End Function
ASKER
-------------------------- -
Windows Script Host
-------------------------- -
Script: C:\Mailbox.vbs
Line: 57
Char: 13
Error: Expected 'End'
Code: 800A03F6
Source: Microsoft VBScript compilation error
-------------------------- -
OK
-------------------------- -
Is there anything that i need to change
Windows Script Host
--------------------------
Script: C:\Mailbox.vbs
Line: 57
Char: 13
Error: Expected 'End'
Code: 800A03F6
Source: Microsoft VBScript compilation error
--------------------------
OK
--------------------------
Is there anything that i need to change
unfortunately i don't have access to run this against my own personal exchange server, so we will have to use trial and error,..
try this version
Const strtextfile = "C:\results.csv"
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper sonate}!\\ " & strComputer & _
"\ROOT\MicrosoftExchangeV2 ")
Set colItems = objWMIService.ExecQuery _
("Select * from Exchange_Mailbox")
if err.number <> 0 then
wscript.echo err.number & " : " & err.description & " : problem connection to" & strComputer
err.clear
end if
Set oFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set oOutput = oFSO.OpenTextFile(strtextf ile,8,True )
Header = "Associated content count" & vbtab & _
"Date discovered absent in directory service: " & vbtab & _
"Delete messages size extended " & vbtab & _
"Last logged-on user account " & vbtab & _
"Last logoff time" & vbtab & _
"Last logon time" & vbtab & _
"Legacy distinguished name" & vbtab & _
"Mailbox display name" & vbtab & _
"Mailbox GUID" & vbtab & _
"Server name" & vbtab & _
"Size" & vbtab & _
"Storage group name" & vbtab & _
"Storage limit information" & vbtab & _
"Store name" & vbtab & _
"Total items" & vbcrlf
oOutput.Write(header)
For Each objItem in colItems
results = results & changenull(objItem.AssocCo ntentCount ) & vbtab
results = results & changenull(objItem.DateDis coveredAbs entInDS) & vbtab
results = results & changenull(objItem.Deleted MessageSiz eExtended) & vbtab
results = results & changenull(objItem.LastLog gedOnUserA ccount) & vbtab
results = results & changenull(objItem.LastLog offTime) & vbtab
results = results & changenull(objItem.LastLog onTime) & vbtab
results = results & changenull(objItem.LegacyD N) & vbtab
results = results & changenull(objItem.Mailbox DisplayNam e) & vbtab
results = results & changenull(objItem.Mailbox GUID) & vbtab
results = results & changenull(objItem.ServerN ame) & vbtab
results = results & changenull(objItem.Size) & vbtab
results = results & changenull(objItem.Storage GroupName) & vbtab
results = results & changenull(objItem.Storage LimitInfo) & vbtab
results = results & changenull(objItem.StoreNa me) & vbtab
results = results & changenull(objItem.TotalIt ems) & vbcrlf
oOutput.Write(Results)
Next
function changenull(item)
'incase things are null
if item = vbempty or item = "" then
item = "NULL"
end if
End Function
try this version
Const strtextfile = "C:\results.csv"
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
"\ROOT\MicrosoftExchangeV2
Set colItems = objWMIService.ExecQuery _
("Select * from Exchange_Mailbox")
if err.number <> 0 then
wscript.echo err.number & " : " & err.description & " : problem connection to" & strComputer
err.clear
end if
Set oFSO = CreateObject("Scripting.Fi
Set oOutput = oFSO.OpenTextFile(strtextf
Header = "Associated content count" & vbtab & _
"Date discovered absent in directory service: " & vbtab & _
"Delete messages size extended " & vbtab & _
"Last logged-on user account " & vbtab & _
"Last logoff time" & vbtab & _
"Last logon time" & vbtab & _
"Legacy distinguished name" & vbtab & _
"Mailbox display name" & vbtab & _
"Mailbox GUID" & vbtab & _
"Server name" & vbtab & _
"Size" & vbtab & _
"Storage group name" & vbtab & _
"Storage limit information" & vbtab & _
"Store name" & vbtab & _
"Total items" & vbcrlf
oOutput.Write(header)
For Each objItem in colItems
results = results & changenull(objItem.AssocCo
results = results & changenull(objItem.DateDis
results = results & changenull(objItem.Deleted
results = results & changenull(objItem.LastLog
results = results & changenull(objItem.LastLog
results = results & changenull(objItem.LastLog
results = results & changenull(objItem.LegacyD
results = results & changenull(objItem.Mailbox
results = results & changenull(objItem.Mailbox
results = results & changenull(objItem.ServerN
results = results & changenull(objItem.Size) & vbtab
results = results & changenull(objItem.Storage
results = results & changenull(objItem.Storage
results = results & changenull(objItem.StoreNa
results = results & changenull(objItem.TotalIt
oOutput.Write(Results)
Next
function changenull(item)
'incase things are null
if item = vbempty or item = "" then
item = "NULL"
end if
End Function
you get the scripts all the time,. you shoudl be able to look through them and notice irregularities,...
if you see an
IF statement, then it requires an END assuming that it is more than one line
if you see an
IF statement, then it requires an END assuming that it is more than one line
ASKER
I get this.
C:\>Exchange.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
C:\Exchange.vbs(59, 6) Microsoft VBScript compilation error: Syntax error
C:\>Exchange.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
C:\Exchange.vbs(59, 6) Microsoft VBScript compilation error: Syntax error
ASKER
I remove the 59th line. I get this...
C:\>Exchange.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
424 : Object required : problem connection to.
C:\>Exchange.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
424 : Object required : problem connection to.
add back line 59 and try changing
strcomputer = "."
to
strcomputer = "exchangeserver"
where exchangeserver is your exchange servername
strcomputer = "."
to
strcomputer = "exchangeserver"
where exchangeserver is your exchange servername
ASKER
The reults come with these junk data.
15MB of file which has full of box symbols in it....
15MB of file which has full of box symbols in it....
open it in excel
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am trying to open i excel only...Ok i think right click is fine for now...
technically mboppe should have gotten the points,.
i merely ran in awild goose chase,. :)
i merely ran in awild goose chase,. :)
ASKER
OOps sorry i did not see his comment.I though he answered for another queston of mine.
Sorry..
mboppe do you want me to open the Q to split points...
Sorry..
mboppe do you want me to open the Q to split points...
Thats okay Sharath.
ASKER
Thanks a lot mboppe to be so kind...
Const strtextfile = "C:\results.csv"
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
"\ROOT\MicrosoftExchangeV2
Set colItems = objWMIService.ExecQuery _
("Select * from Exchange_Mailbox")
Set oFSO = CreateObject("Scripting.Fi
Set oOutput = oFSO.OpenTextFile(strtextf
For Each objItem in colItems
Header = "Associated content count" & vbtab & _
"Date discovered absent in directory service: " & vbtab & _
"Delete messages size extended " & vbtab & _
"Last logged-on user account " & vbtab & _
"Last logoff time" & vbtab & _
"Last logon time" & vbtab & _
"Legacy distinguished name" & vbtab & _
"Mailbox display name" & vbtab & _
"Mailbox GUID" & vbtab & _
"Server name" & vbtab & _
"Size" & vbtab & _
"Storage group name" & vbtab & _
"Storage limit information" & vbtab & _
"Store name" & vbtab & _
"Total items" & vbcrlf
For Each objItem in colItems
changenull(objitem)
results = results & changenull(objItem.AssocCo
results = results & changenull(objItem.DateDis
results = results & changenull(objItem.Deleted
results = results & changenull(objItem.LastLog
results = results & changenull(objItem.LastLog
results = results & changenull(objItem.LastLog
results = results & changenull(objItem.LegacyD
results = results & changenull(objItem.Mailbox
results = results & changenull(objItem.Mailbox
results = results & changenull(objItem.ServerN
results = results & changenull(objItem.Size) & vbtab
results = results & changenull(objItem.Storage
results = results & changenull(objItem.Storage
results = results & changenull(objItem.StoreNa
results = results & changenull(objItem.TotalIt
oOutput.Write(Results)
Next
function changenull(item)
'incase things are null
if item = vbempty or item = "" then
item = "NULL"
End Function