Get Department in EMC 2010 SP1
Hello
I need information about users in specific database, and only First Name, Last Name, E-mail, Department
using EMC.
This One works well, but I cannot get Department, why ? :
Get-Mailbox -ResultSize unlimited -Database "DB1" | Select-Object DisplayName,PrimarySmtpAddress,Department
How to get department info ?
May 30th, 2012 3:49am
Hi
Department is not a property of the mailbox so it is not returned by Get-Mailbox. You need to run Get-User for this instead.
Try this:
Get-Mailbox -ResultSize unlimited -Database "DB1" | Select-Object DisplayName,PrimarySmtpAddress,@{expression={(Get-User $_.name).Department}}
Cheers, Steve
Free Windows Admin Tool Kit Click here and download it now
May 30th, 2012 5:14am
This one is not working.
EMC retunrs :
DisplayName
PrimarySmtpAddress
(Get-User $_.name).Department
-----------
------------------
-----------------------------
May 30th, 2012 8:02am
It should return the correct values, just the label needs to be set. Try this:
Get-Mailbox -ResultSize unlimited -Database "DB1" | Select-Object DisplayName,PrimarySmtpAddress,@{label="Department";expression={(Get-User $_.name).Department}}
Free Windows Admin Tool Kit Click here and download it now
May 30th, 2012 8:47am
Works fine for me, the only thing I would do is tidy it up with a corrected label:
get-mailbox -ResultSize Unlimited -database "DB1" | Select-Object DisplayName,PrimarySmtpAddress,@{label="Department";expression={(Get-user $_.name).Department}}
Are you sure your department fields are populated? Also, if you could paste the command you are using that yields a blank result.
May 30th, 2012 8:58am
Yes, department fields are populated, I tried with FirstName, LastName, but the same. Looks like EMC cannot read data from AD, it can get only data from fields that are listed when you tipe "Select-Object *".
the same:
get-mailbox -ResultSize Unlimited -database "DB1" | Select-Object DisplayName,PrimarySmtpAddress,@{label="Department";expression={(Get-user $_.name).Department}}
EMC retunrs :
DisplayName
PrimarySmtpAddress
Department
-----------
------------------
-----------------------------
data
data
empty
Free Windows Admin Tool Kit Click here and download it now
May 30th, 2012 9:12am
I've just tried this on another system and sometimes it starts completing the department column about half way through the results. The lines before that are blank and I don't know what would cause this.
May 30th, 2012 10:00am
I just saw the same thing, the pipeline does not seem to execute the expression command for a while.... well, the only workaround I can think of is to use the trusty dusty foreach method, it takes a while to run, but it works:
$Mailboxes=Get-Mailbox -ResultSize Unlimited -Database "DB1"
$report=@()
foreach ($mailbox in $mailboxes) {
$ReturnedObj=New-Object PSObject
$ReturnedObj | Add-Member NoteProperty -Name "Display Name" -Value $Mailbox.DisplayName
$ReturnedObj | Add-Member NoteProperty -Name "Primary Email" -Value $Mailbox.PrimarySmtpAddress
$ReturnedObj | Add-Member NoteProperty -Name "Department" -Value $(Get-User $mailbox.name).Department
$Report+=$ReturnedObj
}
$Report
#Uncomment below to export to CSV
#$Report | Export-CSV ".\FileName.CSV" -NoTypeInformation
Free Windows Admin Tool Kit Click here and download it now
May 30th, 2012 10:22am
Yes I think you are on to something there. I just broke the command in two and it returns all the values:
$mbx = Get-Mailbox -ResultSize unlimited -Database "DB1"
$mbx | Select-Object DisplayName,PrimarySmtpAddress,@{label="Department";expression={(Get-User $_.name).Department}}
May 30th, 2012 10:45am
This works too:
Get-Mailbox -ResultSize unlimited -Database "DB1" -OutBuffer 500 | Select-Object DisplayName,PrimarySmtpAddress,@{expression={(Get-User $_.name).Department}}
Adjust the value of OutBuffer depending on your environment and the number of objects returned.
Free Windows Admin Tool Kit Click here and download it now
May 30th, 2012 11:15am
Nice Steve, I will remember that one.
May 30th, 2012 11:31am
Hi Krieghoff
Did you try those Command above? They works fine on my Exhange.
If it works, Please Mark Steve's post As Answer and finish this thread
CheersZi Feng
TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
May 30th, 2012 11:03pm