powershell - Need to get an Exchange 2010 user report -


i'm trying exchange 2010 report multitenant platform. thing need info obtained different cmdlets. our client asking displayname, mailboxplan, primarysmtpaddress (get-mailbox), totalitemsize , lastlogontime (get-mailboxstatistics)

i'm trying using powershell, i'm getting error... can me find out what's wrong?

here's script:

$tbmailbox = get-mailbox -organization organization -resultsize unlimited | select-object identity,displayname,mailboxplan,primarysmtpaddress  foreach ($mbx in $tbmailbox) {$temp += ,(get-mailboxstatistics -identity $mbx.identity | select $mbx.identity,$mbx.displayname,$mbx.mailboxplan,$mbx.primarysmtpaddress,totalitemsize,lastlogontime)}  $temp | export-csv -path "c:\path" 

i'm getting error:

  • foreach ($mbx in $tbmailbox) {$temp += ,(get-mailboxstatistics -identity $mbx.identity | select <<<< $mbx.identity,$mbx.mailboxplan,$mbx.primarysmtpaddress,totalitemsize,lastlogontime)}
    • categoryinfo : invalidargument: (:) [select-object], notsupportedexception
    • fullyqualifiederrorid : dictionarykeyunknowntype,microsoft.powershell.commands.selectobjectcommand select-object : cannot convert microsoft.exchange.data.directory.adobjectid 1 of following types {system.string, system. management.automation.scriptblock}. @ line:1 char:96

any thoughts?

update

tried different approach, same result. think problem here select-object:

get-mailbox -organization organization -resultsize unlimited | foreach-object -process {select-object $_.displayname,$_.mailboxplan,$_.primarysmtpaddress,@{n=”size(mb)”;e = {$mbxstat = get-mailboxstatistics -identity $_.identity; $mbxstat.totalitemsize.value.tomb()}},@{n="lastlogontime";e = {$mbxstat = get-mailboxstatistics -identity $_.identity; $mbxstat.lastlogontime}}} | export-csv "c:\report.csv" 

hint: cannot convert...objectid..to..one of following types...system.string...

don't use select-object, select name, etc.

$tbmailbox = get-mailbox -organization organization -resultsize unlimited | select identity,displayname,mailboxplan,primarysmtpaddress i'll have play "foreach" statement though, that's not how have written it, doesn't mean wouldn't work.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -