Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Powershell Export to CSV does not match information on screen

$
0
0

Hi, I have created the attached PowerShell script, it runs correctly on screen but the information for the "AlternativeSMTP" details is not exporting correctly to the CSV File, it will export for some users that have only one address not for others that have more than one alternative address for these I am getting the "System.Object[]" in the export, how can I get all the information to be exported as it is shown on screen.

________________________

$mbcombCollection = @()

Get-Mailbox -ResultSize Unlimited | Sort -Property DisplayName |foreach-object{

$mbstatis = get-mailboxstatistics $_.identity

$mbcomb = "" | select Displayname, Alias, Servername, EmailAddress, AlternativeSMTP, Mailboxtype, Mailboxsize , StorageLimitStatus, Numitems, WhenCreated, Database, UseDatabaseQuotaDefaults, IssueWarningQuota, ProhibitSendQuota, ProhibitSendReceiveQuota 

 

$mbcomb.displayname = $_.displayname

$mbcomb.alias = $_.Alias

$mbcomb.Servername = $_.Servername

$mbcomb.emailaddress = $_.windowsemailaddress

$mbcomb.mailboxtype = $_.Customattribute1

$mbcomb.mailboxsize = $mbstatis.totalitemsize

$mbcomb.numitems = $mbstatis.itemcount

$mbcomb.usedatabasequotadefaults = $_.usedatabasequotadefaults

$mbcomb.issuewarningquota = $_.issuewarningquota

$mbcomb.prohibitsendquota = $_.prohibitsendquota

$mbcomb.prohibitsendreceivequota = $_.prohibitsendreceivequota

$mbcomb.StorageLimitStatus = $mbstatis.storagelimitstatus

$mbcomb.WhenCreated = $_.WhenCreated

$mbcomb.database = $mbstatis.Database

$mbcomb.AlternativeSMTP = $_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}

 

$mbcombCollection += $mbcomb

}

 

$mbcombCollection

$mbcombCollection | Export-Csv C:\Report\UserInfo.csv -NoTypeInformation


Viewing all articles
Browse latest Browse all 8583

Trending Articles