Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Powershell script request - change DG names and aliases

Posted on 2014-10-20
8
Medium Priority
?
76 Views
Last Modified: 2014-10-20
Looking for a quick PS script to pre-pend all my distribution groups display names and aliases with 'UB_'

Right now I'm going through and manually editing each one, but I've got over 200 of them.
0
Comment
Question by:Ben Hart
[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
  • 4
  • 4
8 Comments
 
LVL 29

Expert Comment

by:becraig
ID: 40393083
Get-DistributionGroup -ResultSize Unlimited | % { $nuname = "UB_" + $_ ; Set-DistributionGroup -Identity $_ -Name $nuname -IgnoreNamingPolicy}

Open in new window


Something like above should work.

If you have a list of groups already then you can pipe in from a text file or csv.
0
 
LVL 14

Author Comment

by:Ben Hart
ID: 40393122
so maybe an Import-CSV c:\blah.csv | foreach {set-distributiongroup % { ......
0
 
LVL 14

Author Comment

by:Ben Hart
ID: 40393148
Actually no that doesnt work.  Hmm
0
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
LVL 29

Accepted Solution

by:
becraig earned 2000 total points
ID: 40393154
Import-Csv blah.csv | %  { $nuname = "UB_" + $_.Name; Set-DistributionGroup -Identity $_.Name -Name $nuname -IgnoreNamingPolicy }

Open in new window


This assumes your csv has a column header named name, eg:

Name
DG1
DG2
DG3
0
 
LVL 14

Author Comment

by:Ben Hart
ID: 40393181
Oh yeah duh.. $_.columnName.

Worked like a champ!

Now is $nuname a specific property field for an object?
0
 
LVL 29

Expert Comment

by:becraig
ID: 40393187
$nuname is the variable we create to hold the value of the new name

$nuname (variable name )

"UB_" + $_.Name; (variable value)

We combine the two strings "UB_" and whatever the value is of the current name to make the new string $nuname which we pass into the command.
0
 
LVL 14

Author Comment

by:Ben Hart
ID: 40393213
Very nice.  Thanks so much!
0
 
LVL 29

Expert Comment

by:becraig
ID: 40393216
No problem, we're here to help.
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

After hours on line I found a solution which pointed to the inherited Active Directory permissions . You have to give/allow permissions to the "Exchange trusted subsystem" for the user in the Active Directory...
Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
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…

688 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