Distribution List - Set-Distribution Group Power Shell
Hello,
I would like to rename a multiple groups at once. Is there a power shell command that I can use? I saw this command online, but it looks like this only updates one group at a time.
https://technet.microsoft.com/en-us/library/bb124955(v=exchg.150).aspx
Set-DistributionGroup -Identity "Accounting" -DisplayName "Accounting Group"
I have about 20 groups and the first portion of their names begins with ABC_ , and I would like to change that to DEF (i.e. ABC_Helpdesk to DEF_Helpdesk...). Than
August 18th, 2015 7:33pm
It's about time for you to learn how to do some PowerShell scripting.
August 18th, 2015 8:46pm
We are using DirSync to update our AD attributes, the changes has to be done on AD and not on Exchange Online. Yes, Ed. so far, I am learning a lot on Power Shell, thanks. Do you have any input?
August 18th, 2015 9:48pm
Create a CSV file name test.csv. Below are the values
old,new
ABC_Helpdesk,DEF_helpdesk
Copy below code and save as set.ps1
$name = import-csv test.csv
foreach ($b in $name)
{
$o = $o1.old
$n = $n1.new
Set-DistributionGroup -Identity "$o" -DisplayName "$n"
}
Run the .ps1 file.
-
Proposed as answer by
Vishwanath.S
4 hours 43 minutes ago
August 18th, 2015 10:48pm
Create a CSV file name test.csv. Below are the values
old,new
ABC_Helpdesk,DEF_helpdesk
Copy below code and save as set.ps1
$name = import-csv test.csv
foreach ($b in $name)
{
$o = $o1.old
$n = $n1.new
Set-DistributionGroup -Identity "$o" -DisplayName "$n"
}
Run the .ps1 file.
-
Proposed as answer by
Vishwanath.S
Wednesday, August 19, 2015 2:47 AM
August 19th, 2015 2:47am
Hi,
Use this command to export all DL information to CSV file.
Get-DistributionGroup | select-object identity,displayname | export-csv C:\DL.csv
Then open this csv file and edit the displayname to what you want, run the following command to set.
Import-Csv "C:\DL.csv" | ForEach-Object{ Set-DistributionGroup Identity $_.Identity DisplayName $_.DisplayName}
Best Regards.
August 19th, 2015 5:03am
Thank you Lynn, I'll give this a try.
August 19th, 2015 10:04am
Thank you Vishwanath, I'll give this a try.
August 19th, 2015 10:04am
Hi Lyn,
If I get all the DL information on the CSV file, let's say I have about 700 groups on the list, but I only need 25 groups to work on, can I then remove the other 625 groups? Is it safe to do that, then after saving my changes, export it to AD? Thanks.
August 20th, 2015 12:31am
Hi Vishwanath,
I just want to understand/learn your codes (in bold):
$name = import-csv test.csv
foreach ($b in $name) = what is this value means?
{
$o = $o1.old = $o1 why are we using this code before the .old?
$n = $n1.new =$n1 why are we using this code before the .new?
Set-DistributionGroup -Identity "$o" -DisplayName "$n"
}
Thanks.
August 20th, 2015 12:43am
Hi,
Yes, it's safe to remove the other 625 groups.
I prefer extracting these 25 groups to another CSV file.
Best Regards.
August 20th, 2015 2:47am