Forum Discussion
Zeff Wheelock
Oct 31, 2017Iron Contributor
Suppressing Text after New-DistributionList
I have a script which I am creating a distribution list (New-DistributionList). However, the format of the output gets screwed up when the following text appears: New! Office 365 Groups are the ...
Nov 06, 2017
Couldnt you do something like this?
Store it to a variable, then give the output depending if its $null or not.
$newDB = New-DistributionGroup -Name $ApproversGroup -Type "Security" -ManagedBy $ApproverOwners -CopyOwnerToMember -Members $Approvers -PrimarySmtpAddress "$($ApproversGroup.Replace(' ','_'))@domain.com"
If($newDB -ne $null) {
"Completed successfully"
}
Else{"Error"}Zeff Wheelock
Nov 07, 2017Iron Contributor
Saving it to a variable won't work either. It still prints the Office 365 group message. I called Microsoft and they acknowledged the message and stated it is there only temporary but they have no timetable when they will remove it. Sometimes, Microsoft just does not think things through...
- Michael DonovanDec 23, 2020Brass ContributorApparently I am not allowed to like this but I whole heartedly agree!
- CameronOveDec 06, 2017Copper Contributor
I experience the same issue and I agree. We should not have to put some crap code to deal with the message. Microsoft should just not present that message or allow us to turn it off via the cmdlet.
Common MS think things through would you?
- Mohamed ShehataDec 05, 2017Former Employee
You create an array and the results to it, similar to below:
$DlArray = @()
$DlArray += "UserPrincipalName" + "," + "Comment"
$DlArray += "Creating security group:" + $_.ApproversGroup
$DlArray += "Creating security group: SG-" + $_.RoomMailboxThis will refine the results, you can add some logic to catch the errors.
- Zeff WheelockDec 06, 2017Iron ContributorIt is not an error though. It order to create a distribution list, you need to use New-DistributionList. As soon as you run it to create the list, then you have that unwanted text and there is no suppressing it. Oh well.
- Michael DonovanDec 23, 2020Brass ContributorApparently I am not allowed to like this either but I whole heartedly agree!