Solved

How to modify the following script to ignore / suppress the warning message and export it to TXT file ?

Posted on 2012-03-14
4
1,319 Views
Last Modified: 2012-03-18
Hi People,

Can anyone assist me in modifying the powershell script below to accept array of Mailboxes and then removing the warning of the invalid alias ?

$DGrps = Get-DistributionGroup -ResultSize Unlimited -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
ForEach ($DGrp in $DGrps) {
	.\enumerate_groups.ps1 $DGrp.get_DisplayName() -showTree
}

Open in new window


my current result is as follows:

Group Name:  Payment - FRAUD COMMITTEE
WARNING: Object domain.com/Exchange 2003/Distribution Lists/Payment - FRAUD COMMITTEE has been corrupted and it is in an inconsistent state. The following validation errors have occurred:
WARNING: "Payment - FRAUD COMMITTEE" is not valid for Alias. Valid values are: Strings formed with characters from a to z (uppercase or lowercase), digits from 0 to 9, !, #, $, %, &, ', *, +, -, /, =, ?, ^, _, `, {, |, } or ~. One or more periods may be embedded in an alias, but each one of them should be preceded and followed by at least one of the other characters. Unicode characters from U+00A1 to U+00FF are also valid in an alias, but they will be mapped to a best-fit US-ASCII string in the email address which is generated from such an alias.
Email Addresses:   Payment@domainad.com  
WARNING: Object domain.com/Exchange 2003/Distribution Lists/Payment - FRAUD COMMITTEE has been corrupted and it is in an inconsistent state. The following validation errors have occurred:
WARNING: "Payment - FRAUD COMMITTEE" is not valid for Alias. Valid values are: Strings formed with characters from a to z (uppercase or lowercase), digits from 0 to 9, !, #, $, %, &, ', *, +, -, /, =, ?, ^, _, `, {, |, } or ~. One or more periods may be embedded in an alias, but each one of them should be preceded and followed by at least one of the other characters. Unicode characters from U+00A1 to U+00FF are also valid in an alias, but they will be mapped to a best-fit US-ASCII string in the email address which is generated from such an alias.

Group Members
-------------
John Durham                                                                                                                                                                    
Vina Roger                                                                                                                                                                     
Delon Bingaro                                                                                                                                                                
Total Execution Time:  2812.5 ms

.........

Open in new window


and how to modify so that the result is exported to .TXT file ?

Note: the script is courtesy of: http://www.tinyint.com/index.php/2009/07/17/enumerate-distribution-groups-script-updated/
0
Comment
[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
  • 2
  • 2
4 Comments
 
LVL 19

Expert Comment

by:suriyaehnop
ID: 37723576
Try this:

$WarningPreference = 'SilentlyContinue' #See more about WarningPreference type Get-help *warning*
$DGrps = Get-DistributionGroup -ResultSize Unlimited -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
ForEach ($DGrp in $DGrps) {
	.\enumerate_groups.ps1 $DGrp.get_DisplayName() -showTree
}

Open in new window

0
 
LVL 8

Author Comment

by:Senior IT System Engineer
ID: 37723585
Thanks for the reply man, so how to export that result into Txt file ?
0
 
LVL 19

Accepted Solution

by:
suriyaehnop earned 500 total points
ID: 37724008
$WarningPreference = 'SilentlyContinue' #See more about WarningPreference type Get-help *warning*
$DGrps = Get-DistributionGroup -ResultSize Unlimited -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
$result = ForEach ($DGrp in $DGrps) {
	.\enumerate_groups.ps1 $DGrp.get_DisplayName() -showTree
}

$result | Format-Table Displayname >c:\filename.txt

Open in new window

0
 
LVL 8

Author Comment

by:Senior IT System Engineer
ID: 37727281
thanks for the reply again mate,
however the DG group members is not showing now ?
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

717 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