SOLVED

Exporting inbox rule from mailbox csv list and export result to CSV file

Steel Contributor

trying to Export inbox rule from 50 mailbox csv list and export result to CSV file but the resulting CSV file only shows 1 user. please check script:

 

Import-Csv "C:\PS\INBOXRULE\LIST.CSV" | foreach { Get-InboxRule -mailbox $_.UserPrincipalName | Export-Csv -Path c:\PS\INBOXRULE\result.CSV }

2 Replies
best response confirmed by Marvin Oco (Steel Contributor)
Solution

You're overwriting the CSV file on each iteration. Add the -Append switch after Export-CSV.

thanks @Vasil Michev

 

Import-Csv "C:\PS\INBOXRULE\LIST.CSV" | foreach { Get-InboxRule -mailbox $_.UserPrincipalName | Export-Csv -Path c:\PS\INBOXRULE\result.CSV -append}

1 best response

Accepted Solutions
best response confirmed by Marvin Oco (Steel Contributor)
Solution

You're overwriting the CSV file on each iteration. Add the -Append switch after Export-CSV.

View solution in original post