views:

602

answers:

3

I have the following code pulling from my exchange server 2003.

     connect-qadservice -service 'localhost'    
foreach ($server in $exchangeservers)
    {
    $AllUsers += get-wmiobject -class Exchange_Mailbox -namespace Root\MicrosoftExchangeV2 -computername $server| select servername,storagegroupname, storename,mailboxdisplayname,totalitems,size, DeletedMessageSizeExtended, legacyDN, datediscoveredabsentInDS
    }
 $exchngver = "2003"

foreach ($user in $AllUsers)
{
  $obj = new-object psObject
  $office = get-qaduser -Identity $user.legacyDN | select office, description
}
disconnect-qadservice

and it doesn't grab all the mailbox stores on the server. Any idea why or what might be causing this?

thanks in advance

NOTE: IT seems to grab all the mailbox stores except for 1 in the 2nd storage group. I have no idea why this is... The funny thing is my vbscript grabs all the mailbox stores using the same namespace and class just fine.

A: 

So to start simple, does it come back correct before you unroll & start using the quest stuff?

Do you get the right number from:

(get-wmiobject -class Exchange_Mailbox -namespace Root\MicrosoftExchangeV2 -computername srv02).count
slipsec
A: 

Couple of things (not sure they are the cause (#1)):

  1. you are looping over $exchangeservers but don't use $server in -computerName (there's a fixed "srv02" server name).

  2. I would move the "connect-qadservice -service 'localhost'" out of the foreach servers loop (You call it for each server in exchangeservers).

  3. You are calling get-qaduser twice ($tmp and $office) to get the user office and description, you can do it in one call ($tmo is redundant):

Shay Levy
i updated that much however it seems it still overlooking one of the storagegroups.
phill
A: 

Have you checked permissions on the Stores/SGs?

slipsec