Andor Oudt
asked on
How to get statistics on the number of users having a auto-forward rule configured
Reader,
I would like to know how many users have configured and are using an auto-forward rule. From what I have so far is that such messages are flagged with 'Source = MAILBOXRULE'
I am working with the command to test the output and see what step to take next. I have generated output, so a hit should be returned, but the output show no results;
"Get-TransportServer | Get-MessageTrackingLog -Start "12/05/2011 15:00:00" -Recipient "<specific SMTP address>" -Sender "<specific SMTP address>" |FL MAILBOXRULE"
The desired result is to have a log-file showing all the users that have an auto-forward rule configured (name, source, sender are values I would like to have in the overview).
I would like to know how many users have configured and are using an auto-forward rule. From what I have so far is that such messages are flagged with 'Source = MAILBOXRULE'
I am working with the command to test the output and see what step to take next. I have generated output, so a hit should be returned, but the output show no results;
"Get-TransportServer | Get-MessageTrackingLog -Start "12/05/2011 15:00:00" -Recipient "<specific SMTP address>" -Sender "<specific SMTP address>" |FL MAILBOXRULE"
The desired result is to have a log-file showing all the users that have an auto-forward rule configured (name, source, sender are values I would like to have in the overview).
Hi, I'm not too good with Powershell, and I don't use Exchange, but I think the user properties that would interest you are the altRecipient property, and / or the deliverAndRedirect property.
Maybe something like this would work.
Regards,
Rob.
Maybe something like this would work.
Regards,
Rob.
$domain = "dc=nwtraders,dc=com"
$dse = [adsi]"LDAP://$domain"
$filter = '(&(objectCategory=person)(objectSid=*)(!samAccountType:1.2.840.113556.1.4.804:=3)(deliverAndRedirect=$true))'
$searcher = New-Object DirectoryServices.DirectorySearcher ($dse, $filter)
$searcher.findall() |
ForEach-Object {
[adsi]$_.path
} |
Format-Table -AutoSize -Property name, altRecipient, deliverAndRedirect
ASKER
Thanks for this. I will be able to test this tomorrow and will let you know the outcome and results.
As described int he below article you could get a list all the inbox rules and then may a quick seacrh should be able to get the require information.
http://www.msexchange.org/articles_tutorials/exchange-server-2010/management-administration/managing-inbox-rules-exchange-server-2010.html
http://www.msexchange.org/articles_tutorials/exchange-server-2010/management-administration/managing-inbox-rules-exchange-server-2010.html
ASKER
Rob, thanks for participating, but I am unsure how to proceed; how to incorporate this in a Powershell script?
I feel that the second suggestion/solution will provide the desired results, using the methods incorporated within the Exchange management infrastructure and mboppe, I think this is (exactly) what I am looking for, as a solution to the question.
Thanks for both suggestions/possible solutions, I will let you know as soon what the results are.
I feel that the second suggestion/solution will provide the desired results, using the methods incorporated within the Exchange management infrastructure and mboppe, I think this is (exactly) what I am looking for, as a solution to the question.
Thanks for both suggestions/possible solutions, I will let you know as soon what the results are.
Sure, if mboppe's solution meets your needs, then don't worry about the script I posted. It *is* a Powershell script, though, so you can just put it into a .PS1 file and run it with Powershell. You will need to change the domain name though, and then see what output you get.
Rob.
Rob.
ASKER
Be assured that I am going to 'try' both suggested solutions and, if equally useful, points will be distributed accordingly... thanks again
Currently think that I will have a 'test-run' in two hours.
Currently think that I will have a 'test-run' in two hours.
ASKER
OK....
Thanks to the heads-up from RobSampson & mboppe I have found a possible method to extract data from all mailboxes configured with a RedirectTo rule.
This is what I am using now, but the output (at least WARNING: information) is directly generated on screen and I need to include all output in a log file:
Any thoughts on improving the script?
Thanks to the heads-up from RobSampson & mboppe I have found a possible method to extract data from all mailboxes configured with a RedirectTo rule.
This is what I am using now, but the output (at least WARNING: information) is directly generated on screen and I need to include all output in a log file:
foreach ($i in (Get-Mailbox -ResultSize unlimited)) { Get-InboxRule -Mailbox $i.DistinguishedName | where {$_.RedirectTo} | fl MailboxOwnerID,RedirectTo | Export-Csv C:\Users\Public\Documents\Get-InboxRule_RedirectTo.csv }
Any thoughts on improving the script?
Hi, again, I'm not too good with Powershell, but your script looks fine. To output warnings as well, hopefully something like this will work.
Regards,
Rob.
Regards,
Rob.
$outputFile = "C:\Users\Public\Documents\Get-InboxRule_RedirectTo.csv"
$erroractionpreference = "SilentlyContinue"
foreach ($i in (Get-Mailbox -ResultSize unlimited)) { Get-InboxRule -Mailbox $i.DistinguishedName | where {$_.RedirectTo} | fl MailboxOwnerID,RedirectTo | Export-Csv $outputFile }
Write-Output $Error[($Error.count-1)..0] | Out-File -append $outputFile
ASKER
Hi Rob, thanks again....that simply looks exactly what it needs to do.....and more important, what I want to achieve.
I am currently enjoying some Poweshell Off time, but will definitely put your suggestion to good use, first thing tomorrow, when I hit the desk!
Cheers, again!
I am currently enjoying some Poweshell Off time, but will definitely put your suggestion to good use, first thing tomorrow, when I hit the desk!
Cheers, again!
Thanks No-rad
let us know if you need any more help
let us know if you need any more help
ASKER
Yes, I need some more help.
When running the code provided by Rob, output is generated in the file, but displays errors, and I cannot seem to figure out why. I have attached the (sanitized) output file.
When running the initial code, removing the export/save functionality, I get exactly what I need:
MailboxOwnerId : <DN>
RedirectTo : <SMTP address>
The thing is (and this is key), that the script only generates the output 'on screen'
I am definitely missing something obviously simple here, but I cannot seem to find what....
Thanks again for all the effort!
When running the code provided by Rob, output is generated in the file, but displays errors, and I cannot seem to figure out why. I have attached the (sanitized) output file.
When running the initial code, removing the export/save functionality, I get exactly what I need:
MailboxOwnerId : <DN>
RedirectTo : <SMTP address>
The thing is (and this is key), that the script only generates the output 'on screen'
I am definitely missing something obviously simple here, but I cannot seem to find what....
Thanks again for all the effort!
foreach ($i in (Get-Mailbox -ResultSize unlimited)) { Get-InboxRule -Mailbox $i.DistinguishedName | where {$_.RedirectTo} | FL MailboxOwnerID,RedirectTo }
RedirectTo.log
I forgot to add
$error.clear()
to the top of my code. I think that all the errors in that log, except the last one, are actually old errors from the error buffer from other scripts. The last error states:
.\d:\deliverandredirect.ps 1
cannot be found, which may be correct.
Try this and see what you get on screen.
Rob.
$error.clear()
to the top of my code. I think that all the errors in that log, except the last one, are actually old errors from the error buffer from other scripts. The last error states:
.\d:\deliverandredirect.ps
cannot be found, which may be correct.
Try this and see what you get on screen.
Rob.
$error.clear()
$outputFile = "C:\Users\Public\Documents\Get-InboxRule_RedirectTo.csv"
$erroractionpreference = "SilentlyContinue"
foreach ($i in (Get-Mailbox -ResultSize unlimited)) { Get-InboxRule -Mailbox $i.DistinguishedName | where {$_.RedirectTo} | fl MailboxOwnerID,RedirectTo}
Write-Output $Error[($Error.count-1)..0]
ASKER
Hi Rob, Thanks for your continued effort in trying to assist. Super!
I already made some progress *, the following script generates and saves the requested/desired output:
But only the MailboxOwnerID and RedirectTo values are written in the file. What I would like to add is DisplayName (instead of MailboxOwnerID) and PrimarySmtpAddress, but these values are from Get-Mailbox cmd-let.
Is there a way to get this information and also put it in the file? And are there any possibilities to influence the way the CSV file is being populated with data (EG can I custom format the output)?
I am going to execute your suggestion, right after I've stopped typing here!
Thanks again....
* being fairly new at Powershell, you can say it's a small step for you, but a big leap for me ;)
I already made some progress *, the following script generates and saves the requested/desired output:
foreach ($i in (Get-Mailbox -ResultSize unlimited)) { Get-InboxRule -Mailbox $i.DistinguishedName | where {$_.RedirectTo} | FL MailboxOwnerID,RedirectTo | Out-File -Append -FilePath c:\users\public\documents\RedirectTo.csv }
But only the MailboxOwnerID and RedirectTo values are written in the file. What I would like to add is DisplayName (instead of MailboxOwnerID) and PrimarySmtpAddress, but these values are from Get-Mailbox cmd-let.
Is there a way to get this information and also put it in the file? And are there any possibilities to influence the way the CSV file is being populated with data (EG can I custom format the output)?
I am going to execute your suggestion, right after I've stopped typing here!
Thanks again....
* being fairly new at Powershell, you can say it's a small step for you, but a big leap for me ;)
ASKER
Rob,
Just ran your script and it provides the desired results.
I have added " | Out-File -append $outputFile", after Write-Ouput $.... and I am executing another run
This is looking good!
Just ran your script and it provides the desired results.
I have added " | Out-File -append $outputFile", after Write-Ouput $.... and I am executing another run
This is looking good!
ASKER
Added the specifics, but the results are still displayed on screen.
So what was giving you the right result on screen before you added the
| Out-File -append $outputFile
part?
| Out-File -append $outputFile
part?
ASKER
This:
$error.clear()
$outputFile = "C:\Users\Public\Documents\Get-InboxRule_RedirectTo.csv"
$erroractionpreference = "SilentlyContinue"
foreach ($i in (Get-Mailbox -ResultSize unlimited)) { Get-InboxRule -Mailbox $i.DistinguishedName | where {$_.RedirectTo} | fl MailboxOwnerID,RedirectTo}
Write-Output $Error[($Error.count-1)..0]
ASKER
And this one does the trick as well, maybe slightly better:
foreach ($i in (Get-Mailbox -ResultSize unlimited)) { Get-InboxRule -Mailbox $i.DistinguishedName | Where {$_.RedirectTo -like "*SMTP:*"} | FL MailboxOwnerID,RedirectTo | Out-File -Append -FilePath c:\users\public\documents\RedirectTo.csv }
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi Rob,
can you throws some light on this question.
Q_27465808.html
can you throws some light on this question.
Q_27465808.html
ASKER
Rob, You are right.
I ran the script and the output is generated/saved, but it doesn't show the warning messages in the same output. Although this is a 'nice-to-have' it doesn't constrain further analysis.
Based on the output I realized I need to find a way to match the MailboxOwnerId to the SMTP address belonging to that specific mailboxOwnerId. The value PrimarySmtpAddress is not a value that belongs to the Get-InboxRule cmd-let, the value belongs to the Get-Mailbox cmd-let
Because I need to match the two, I have the feeling that the value from one has to be piped into the output of the other cmd-let, shown as a third (MailboxOwnerID,RedirectTo ,PrimarySm tpAddress) result. Although I think this can be achieved, I cannot seem to get this to work, in a one script.
Any thoughts?
I ran the script and the output is generated/saved, but it doesn't show the warning messages in the same output. Although this is a 'nice-to-have' it doesn't constrain further analysis.
Based on the output I realized I need to find a way to match the MailboxOwnerId to the SMTP address belonging to that specific mailboxOwnerId. The value PrimarySmtpAddress is not a value that belongs to the Get-InboxRule cmd-let, the value belongs to the Get-Mailbox cmd-let
Because I need to match the two, I have the feeling that the value from one has to be piped into the output of the other cmd-let, shown as a third (MailboxOwnerID,RedirectTo
Any thoughts?
ASKER
What I need in the final script, is to combine the output of two scripts, generating one log-file that has all the values required (MailboxOwnerID,RedirectTo ,PrimarySm tpAddress) , using the set criteria (Where {$_.RedirectTo -like "*SMTP:*"})
RedirectTo:
RedirectTo:
foreach ($i in (Get-Mailbox -ResultSize unlimited)) { Get-InboxRule -Mailbox $i.DistinguishedName | Where {$_.RedirectTo -like "*SMTP:*"} | FL MailboxOwnerID,RedirectTo }
UserMailbox:foreach ($i in (Get-Mailbox -ResultSize unlimited)) { Get-Mailbox -RecipientType UserMailbox -Identity $i.SamAccountName -ResultSize unlimited | FL Name,DisplayName,PrimarySmtpAddress }
ASKER
OK, I understand... perhaps I was getting a bit ahead of myself, trying to complement and complete the initial request and added some new requirements along the way.
I was just hoping to understand the script process a bit better, with your help.
Anyway the initial request has been answered and addressed by Rob, I suppose (even though the error output is still to be answered, in my opinion).
Thank you all for you continued support in this!
I was just hoping to understand the script process a bit better, with your help.
Anyway the initial request has been answered and addressed by Rob, I suppose (even though the error output is still to be answered, in my opinion).
Thank you all for you continued support in this!
ASKER
Even though the script generates the desired outcome, without the ability to log the errors, I suppose the one liner Powershell script is sufficient and as efficient.
Sorry. I'm not that good with Powershell. If you need further assistance with it, try posting another question in the Powershell zone and see if some more experienced coders can help you out.
Rob.
Rob.
ASKER