Can Powershell insert mailbox size query results into SQL?


I have a little status webpage that I use to display a couple of different things.  Sort of like a system monitoring webpage.  I'd like to display the number of items in my journalling mailbox on that webpage.  It would be great if the server-side code (.net) could ask the Exchange 2007 for that info directly, but it sounds very complicated.

The alternative thought was to have a scheduled task run a powershell script that pulls the data and inserts it into a database for my page to read.

What do you think?  If it's the latter idea, how do I do it?

Thanks for the help!

Who is Participating?
Jamie McKillopIT ManagerCommented:

You could do it with a scheduled task. You would get the number of items in the mailbox with this command:

$itemcount = (get-mailboxstatistics <mailbox>).itemcount

You could then use powershell to inset this into a SQL database. This post explains how to do that:

ddotsonAuthor Commented:
This looks good.  The other item I need it the mailbox size.  I tried $itemcount = (get-mailboxstatistics <mailbox>).totalitemsize, but I got this

[PS] C:\Windows\system32>(get-mailboxstatistics -identity <mailbox>).totalitemsize

                            IsUnlimited Value
                            ----------- -----
                                  False 1563669133B

Open in new window

How can I just get the value?
ddotsonAuthor Commented:
Jamie McKillopIT ManagerCommented:
Add .value to the end.

ddotsonAuthor Commented:
Awesome.  Just what I needed.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.