views:

1724

answers:

4

I wrote this small script to pull the office property from get-user by piping 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 don't get any output or red errors. just the warning:

WARNING:There is no data to return for the specifed mailbox 'Globe/MobileElect Usertemplate', because it has not been logged on to. WARNING:By default only the first 1000 items are returned. To change the number of items returned, specify the parameter "-ResultSize". To return all items specify "-ResultSize Unilimited" (Note: REturning all items maytake a long time and consume a large amount of memory depending on the actual number of items). It is not recommended to store the results in a variable; instead pipe the results to another task or script to perform batch changes.

Any ideas on what might be causing this?

A: 

would a better way to find the office property in Active directory is through binding the GUID property?

I noticed the get-mailboxstatistics has a mailboxguid and the get-user has a guid property.

phill
A: 

I believe the problem is that you're accessing a mailbox that's never been accessed normally. Can you try this with a mailbox that you know the owner has opened and worked with? Or is that already the case?

Also, as 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 absolutely certain using a cmdlet like Get-QADUser, vs. Get-User in Exchange, will ultimately bring you more satisfaction. We just need to mesh up the right property from Get-MailboxStatistics to something Get-QADUser can consume, so that it can get you the right user.

It might also be a bit helpful to understand what your end goal is - possibly there's an entirely different approach that will get you to where you want to be.

Don Jones
A: 

My goal is to develop a script which executes once a day via scheduled task which compiles all mailbox names, mailbox sizes, totalitems, totaldeleted items, along with their office and description fields (from active directory).

I'm guessing the get-qaduser is part of the quest powershell addon. I'll install it locally and give it a try..

the identiy property seems to give a number similar to the guid which looks like 1234as01-4f54-1234-b1df-f1df1df12d2d

I tried running

get-user -identity 1234as01-4f54-1234-b1df-f1df1df12d2d

and it found a name (joey blasio) and recipient type (usermailbox)

then i ran

get-user -Identity 1234as01-4f54-1234-b1df-f1df1df12d2d | select displayname, distinguistedname

Displayname (Joey Blasio ) and DistinguishedName (CN=Joey Blasio,OU=EWE,DC=BLA-1,DC=net)

phill
A: 

It is done by 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
phill