Solved

exchange powershell, vbs

Posted on 2013-05-15
13
246 Views
Last Modified: 2013-05-17
Hi Experts,

I need help (hmm I will not ask if don't need to 0_O) I need a report by email of the following scenario:

1. A script which will get all Exchange Journal Email Address (Distribution List)
2. Get all members of that Exchange Journal Email Address
3. Get user of a Active Directory OU (users)
4. Compare if a member of AD OU is in one of Journalling Email Address
5. Send report: No issue to report (if 0), Issue found if there's a match.

i hope i'm clear to every one!  thank you as always!!!

either vbs or ps will do... :)
0
Comment
Question by:Jaime Umali
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
13 Comments
 
LVL 70

Expert Comment

by:Qlemo
ID: 39167638
Please check if the OU retrieved by Exchange is sufficient to check for:
   Get-DistributionGroupmember "YourDL" | select name, organizationalunit
0
 
LVL 2

Author Comment

by:Jaime Umali
ID: 39167856
thanks Qlemo, apperently this will work, however, i wanted to query the JournalRule side first and get the "Recipient" (DLs) in it and pipe it to get the members in it then compare those members if it exists on a specific OU.

ex. Get-JournalRule | select recipient | (from here I don't know how to get members of those DLs)
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 39168514
Ah, I read "Exchange Journal Email Address" as to be a DL.
Are you sure
   Get-JournalRule | select recipient
works for getting the DLs? If that is true, or you are able to modify it to get the DLs, we just need to pipe it into above line, and you get all users of those OUs.

I don't get the reason behind your request. You do not want anybody to receive journals?
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 2

Author Comment

by:Jaime Umali
ID: 39170581
actually when I execute Get-JournalRule | select recipient, It gives me 20 lists of DLs (as recipient of the JRule) it means that all users on that DLs are part of this Journal Rule, this rule is created by another team, what I want to achieve is to check my users if they are part of this JournalRule (DLs in JournalRule) so we could monitor every day, if one of my user is part I have to ask the team who created that those Rule to remove my users.
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 39170627
$ou = "Your OU to check for here"
$names = Get-JournalRule | select recipient |
   Get-DistributionGroupmember | where { $_.organizationalunit = $ou } | select Name
if ($names)
{
  $Subject = "Journal DL check - found issues"
  $message = "OU = $ou has following members being in the journaling DLs:`r`n" + ($names -join "`r`n")
} else {
  $Subject = "Journal DL check - ok"
  $message = 'No issues found for OU = $ou"
}
Send-MailMessage -From DontKnow@here.com -To WhoEver@there.com -Subject $Subject -Body $message -SmtpServer YourSMTPServerHere

Open in new window

0
 
LVL 2

Author Comment

by:Jaime Umali
ID: 39170676
I will try this and update you!!! thanks!
0
 
LVL 2

Author Comment

by:Jaime Umali
ID: 39170696
giving me this error:

You must provide a value expression on the right-hand side of the '-' operator.
At line:6 char:91
+   $message = "OU = $ou has following members being in the journaling DLs:`r`n
" + ($names -j <<<< oin "`r`n")
0
 
LVL 2

Author Comment

by:Jaime Umali
ID: 39170699
actually this part seems to break:

Get-JournalRule | select recipient | Get-DistributionGroupmember

[PS] C:\Windows\System32>Get-JournalRule | select recipient | Get-DistributionGr
oupMember
Get-DistributionGroupMember : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At line:1 char:64
0
 
LVL 2

Author Comment

by:Jaime Umali
ID: 39170749
Sorry i think i misguided you, when I execute  --- get-JournalRule | Select recipient -- i get the WindowsEmailAddress of the DL... so that is why "Get-DistributionGroupMember" fails :(
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 39170935
Hope this one works for you. The Exchange cmdlets are somewhat silly and acting in a non-standard way, as you should be able to just pipe contents thru without issues.
$ou = "Your OU to check for here"

$names = Get-JournalRule | foreach {
	$dl = $_.Recipient
	Get-DistributionGroup -Filter { PrimarySmtpAddress -eq $dl }
} | Get-DistributionGroupMember -ResultSize unlimited |
  where { $_.organizationalunit -eq $ou } | select Name

if ($names)
{
  $Subject = "Journal DL check - found issues"
  $message = "OU = $ou has following members being in the journaling DLs:`r`n" + ($names -join "`r`n")
} else {
  $Subject = "Journal DL check - ok"
  $message = "No issues found for OU = $ou"
}
Send-MailMessage -From DontKnow@here.com -To WhoEver@there.com -Subject $Subject -Body $message -SmtpServer YourSMTPServerHere

Open in new window

0
 
LVL 2

Author Comment

by:Jaime Umali
ID: 39174325
its getting there but:

You must provide a value expression on the right-hand side of the '-' operator.
At line:4 char:91
+   $message = "OU = $ou has following members being in the journaling DLs:`r`n
" + ($names -j <<<< oin "`r`n")

:)
0
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39174361
Are you using PowerShell v1? If so, you should change that as soon as possible! There is no reason not to use 2.0.
Meanwhile you can change that line (12) to:
  $message = "OU = $ou has following members being in the journaling DLs:`r`n" + ($names.Join("`r`n"))

Open in new window

0
 
LVL 2

Author Closing Comment

by:Jaime Umali
ID: 39175106
Thanks matey!! i will tweak a bit but i can work from here :) :) :)
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question