Hi Peepls,
I’ve been trying to fix this for a number of days, I can get the output to display from the console, just not exported. If the PSObject returns one object the export-CSV works.
Essentially I am creating two variables containing different mailbox settings. From here I am then creating a new PSObject with the required information. I am just unable to export it to CSV.
$SharedMBX = Get-Mailbox -ResultSize unlimited -RecipientTypeDetails SharedMailbox | where {($_.Name -notlike "Room -*") -and ($_.Name -notlike "*Calendar - *") -and ($_.Name -notlike "Address Book - *") -and ($_.Name -notlike "365*") -and ($_.LitigationHoldEnabled -eq $FALSE)}
$CAS = $SharedMBX | Get-CASMailbox -resultsize unlimited | Select Name, OWAEnabled, OWAMailboxPolicy, POPEnabled, ImapEnabled, ActiveSyncEnabled
$report= New-Object PsObject
#Get-Mailbox Settings
$report | Add-Member -MemberType NoteProperty -Name DisplayName -Value $SharedMBX.Name
$report | Add-Member -MemberType NoteProperty -Name PrimarySMTPAddress -Value $SharedMBX.PrimarySMTPAddress
$report | Add-Member -MemberType NoteProperty -Name LitigationHoldEnabled -Value $SharedMBX.LitigationHoldEnabled
$report | Add-Member -MemberType NoteProperty -Name AddressBookPolicy -Value $SharedMBX.AddressBookPolicy
$report | Add-Member -MemberType NoteProperty -Name RetentionPolicy -Value $SharedMBX.RetentionPolicy
$report | Add-Member -MemberType NoteProperty -Name IssueWarningQuota -Value $SharedMBX.IssueWarningQuota
$report | Add-Member -MemberType NoteProperty -Name ProhibitSendQuota -Value $SharedMBX.ProhibitSendQuota
$report | Add-Member -MemberType NoteProperty -Name ProhibitSendReceiveQuota -Value $SharedMBX.ProhibitSendReceiveQuota
$report | Add-Member -MemberType NoteProperty -Name RetainDeletedItemsFor -Value $SharedMBX.RetainDeletedItemsFor
$report | Add-Member -MemberType NoteProperty -Name MessageCopyForSentAsEnabled -Value $SharedMBX.MessageCopyForSentAsEnabled
$report | Add-Member -MemberType NoteProperty -Name MessageCopyForSendonBehalfOfEnabled -Value $SharedMBX.MessageCopyForSendOnBehalfEnabled
#CAS Mailbox Settings
$report | Add-Member -MemberType NoteProperty -Name OWAEnabled -Value $CAS.OWAEnabled
$report | Add-Member -MemberType NoteProperty -Name OWAMailboxPolicy -Value $CAS.OWAMailboxPolicy
$report | Add-Member -MemberType NoteProperty -Name PopEnabled -Value $CAS.PopEnabled
$report | Add-Member -MemberType NoteProperty -Name ImapEnabled -Value $CAS.ImapEnabled
$report | Add-Member -MemberType NoteProperty -Name ActiveSyncEnabled -Value $CAS.ActiveSyncEnabled
$report
This returns the following in the console:
DisplayName : {IT Training, ITD Project Office}
PrimarySMTPAddress : {ITTraining@domain.com, ITDProjectOffice@domain.com}
LitigationHoldEnabled : {False, False}
AddressBookPolicy : {ABP, ABP}
RetentionPolicy : {Delete Deleted Items After 30 Days, Delete Deleted Items After 30 Days}
IssueWarningQuota : {9.9 GB (10,630,044,672 bytes), 9.9 GB (10,630,044,672 bytes)}
ProhibitSendQuota : {9.95 GB (10,683,731,968 bytes), 9.95 GB (10,683,731,968 bytes)}
ProhibitSendReceiveQuota : {10 GB (10,737,418,240 bytes), 10 GB (10,737,418,240 bytes)}
RetainDeletedItemsFor : {30.00:00:00, 30.00:00:00}
MessageCopyForSentAsEnabled : {True, True}
MessageCopyForSendonBehalfOfEnabled : {True, True}
OWAEnabled : {True, True}
OWAMailboxPolicy : {OwaMailboxPolicy-BlockAttachments, OwaMailboxPolicy-BlockAttachments}
PopEnabled : {True, False}
ImapEnabled : {False, True}
ActiveSyncEnabled : {True, True}
Is it even possible to export the data this way? or am I going about this the wrong way?
Any advice welcome.