Solved

exchange powershell, vbs

Posted on 2013-05-15
13
239 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
how to add IIS SMTP to handle application/Scanner relays into office 365.

919 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

21 Experts available now in Live!

Get 1:1 Help Now