Powershell exchange: finding active office real estate
I wrote this little script to pull the office property from get-user by linking the exchange mailbox object.
$server = "tms08"
$arrUser = get-mailbox -Server $server |Get-MailboxStatistics |select identity
foreach ( $id in $arrUuser)
{
$office = get-user -Identity $id.Identity |select office
$out += $id.Identity
}
$out
I am not getting any output or red errors. just a warning:
WARNING: There is no data to return the specified mailbox "Globe / MobileElect Usertemplate" because it has not been registered. WARNING: By default, only the first 1000 items are returned. To change the number of items returned, specify the "-ResultSize" parameter. To return all items specify "-ResultSize Unilimited" (Note: returning all items can take a long time and consume a large amount of memory depending on the actual number of items). It is not recommended to save the results to a variable; instead, another task or script to perform batch changes.
Any ideas on what might be causing this?
My goal is to develop a script that runs once a day with a scheduled task that concatenates all mailbox names, mailbox sizes, totalitems, totaldeleted items along with their office and description fields (from the active directory).
I assume get-qaduser is part of the quest powershell addons. I will install it locally and try it out.
the identiy property seems to give a guid like number that looks like 1234as01-4f54-1234-b1df-f1df1df12d2d
I tried to run
get-user -identity 1234as01-4f54-1234-b1df-f1df1df12d2d
and it found the name (joey blasio) and the recipient type (usermailbox)
then i ran
get-user -Identity 1234as01-4f54-1234-b1df-f1df1df12d2d | select displayname, distinguistedname
Display name (Joey Blasio) and DistinguishedName (CN = Joey Blasio, OU = EWE, DC = UAV-1, DC = net)
source to share
I believe the problem is that you are accessing a mailbox that has never been accessed normally. Can you try this with a mailbox that you know has opened and worked with the owner? Or is it already so?
Also, since I don't have access to my Exchange machine at the moment, can you give me an idea of what the Identity property contains? I'm pretty sure you will have more fun using the Get-QADUser
Cons cmdlets Get-User
in Exchange. We just need to bind the correct property from Get-MailboxStatistics
with what Get-QADUser
can be consumed in order to get the correct user.
It can also be a little helpful to understand what your ultimate goal is - perhaps there is a completely different approach that will get you where you want to be.
source to share
This is done with DisplayName
$exchangeservers = Get-MailboxServer
$AllUsers = @()
$AllUsersEmail = @()
foreach ($server in $exchangeservers)
{
$AllUsers += Get-Mailbox -Server $server |Get-MailboxStatistics |select servername,displayname,itemcount,totalitemsize
}
foreach ($user in $AllUsers)
{
$obj = new-object psObject
$mailinfo = get-mailbox -identity $user.displayname |select PrimarySMTPAddress,Office, DistinguishedName
$tmp = [adsi]("LDAP://" + $mailinfo.DistinguishedName)
$obj |Add-Member -MemberType noteproperty -Name "Server Name" -Value $user.ServerName
$obj |Add-Member -MemberType noteproperty -Name "Display Name" -Value $user.DisplayName
$obj |Add-Member -MemberType noteproperty -Name "Item Count" -Value $user.ItemCount
$obj |Add-Member -MemberType noteproperty -Name "Total Item Size" -Value $user.TotalItemSize
$obj |Add-Member -MemberType noteproperty -Name "Email Address" -Value $mailinfo.PrimarySMTPAddress
$obj |Add-Member -MemberType noteproperty -Name "Office" -Value $mailinfo.Office
$obj |Add-Member -MemberType noteproperty -Name "Description" -Value $tmp.description
$AllUsersEmail += $obj
}
$AllUsersEmail |Export-Csv c:\test.csv -NoTypeInformation
source to share