Solved

exchange powershell, vbs

Posted on 2013-05-15
13
241 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 69

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 69

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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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 69

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 69

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 69

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

Suggested Solutions

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

785 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