[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

exchange powershell, vbs

Posted on 2013-05-15
13
Medium Priority
?
251 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 71

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 71

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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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 71

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 71

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 71

Accepted Solution

by:
Qlemo earned 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
Want to know how to use Exchange Server Eseutil command? Go through this article as it gives you the know-how.
In this video we show how to create a mailbox database 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 Servers >> Data…
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…
Suggested Courses

650 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