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,304 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
  • 2
  • 2
4 Comments
 
LVL 18

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 7

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 18

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 7

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

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.

Question has a verified solution.

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

Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
To show how to generate a certificate request 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 >> Certificates…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

792 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