Solved

exchange powershell, vbs

Posted on 2013-05-15
13
238 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
  • 8
  • 5
13 Comments
 
LVL 68

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 68

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
 
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 68

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 68

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 68

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
In this video we show how to create a Shared Mailbox 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 Recipients >> Sha…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now