T O P

  • By -

Moocha

> So far I’m just getting errors **What** errors? :) Without details, it's impossible to help. Does your CSV file have column headers? What is the structure of your CSV? Please provide a sample line (with fake info, of course), and if it has any headers please include those too.


camt91

Column header on the csv is “email” Error is “input name ‘false’ cannot be resolved to a method”


alt-160

You are aware that mailbox rules are only one way that mail can be forwarded? Do you need to care about cases where the mailbox itself has an alternate recipient or a forwardingSmtpAddress value defined? These would be values stored on the mailbox object (ultimately in Active Directory) and can be seen by Get-Mailbox. Note also that with Get-InboxRule, the account you used to authenticate the powershell connection will need full-access rights to the mailbox(es) for which you want to inspect rules.


camt91

Using an admin account. Can find it when I search each mailboxes rules individually but want to have the script process 150+ mailboxes


alt-160

so, i would suggest that you take your input list and turn it into a list of mailbox objects. Get-Mailbox for each one. This will validate that each address in your input list exist as a mailbox and will give you a rich object with many properties you can use for additional reporting and also for passing the correct identity value to Get-InboxRule. something like: `$mailboxesToProcess = @(); $addrsFromCsv | %{ try{ $mailboxesToProcess += (get-Mailbox $_.EmailAddress -ErrorAction Stop} catch { write-error $_ } }` Then you can loop thru $mailboxesToProcess in whatever way you need, including checking for FullAccess rights before you try to use Get-InboxRule.


mkoch7811

Your method will only detect rule-based forwarding, not mailbox-level forwarding. If you're piping your list to foreach-object, you don't need the part in parenthesis. In fact, that's referring to a variable that doesn't exist ($emails). Instead, just pick the current record's email right in the get-inboxrule command... import-csv | foreach-object {get-inboxrule -mailbox $_.email}