Avatar of ei00004
ei00004
Flag for United States of America asked on

PS command to link a Retention Policy tag without deleting Existing tags in Exchange 2010

Is it possible to link more than one retention policy tag to a retention policy? If so, then what is the PowerShell command to do this?

ExchangePowershell* Retention PolicyOutlook

Avatar of undefined
Last Comment
ei00004

8/22/2022 - Mon
Michael B. Smith

ei00004

ASKER
Hello Michael, The PS command in the link you sent replaces all existing policy tags in the retention policy with the policy tag in the statement, it does not add the policy tags to the existing tags. I'm actually needing a way to add policy tags to the existing tags via PS.
 
Michael B. Smith

And that's the command you use.
$pol = Get-RetentionPolicy <policy-name>
$tag = Get-RetentionPolicyTag <new-tag-name>
$ary = $pol.RetentionPolicyTagLinks | select -exp DistinguishedName
$ary += $tag.DistinguishedName
Set-RetentionPolicy <policy-name> -RetentionPolicyTagLinks $ary

Open in new window

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ei00004

ASKER
Thanks for the script, however when I run it, the script fails with "No retention policy tag with name"
CN=The Existing Policy Tag,DC=Domain,DC=comCN=New Policy Tag to Add,DC=Domain,DC=com
Although I'm not a PS programmer, it appears to fail due to no separator (shown in bold above) between the Existing policy name and the New Policy to be added name.
Michael B. Smith

I tested it before I sent it to you.

I just had a thought. Does the existing retention policy only have one tag?
ei00004

ASKER
Yes it does.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
Michael B. Smith

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ei00004

ASKER
At the end of line 5, shouldn't $a be $ary? I ran the script using $ary at the end of line 5, if I already have one tag in the policy the script will add a second tag. If I have two tags in the policy the script will replace the 2nd tag with the new tag to be added.
Michael B. Smith

Yes, fixed above. I tried this with one through five tags and it works. It never replaces, it always appends.
ei00004

ASKER
Ok I just ran it again and this time it did add a 3rd tag.
Question: Isn't the ability to add tags determine by the TYPE of tag you are trying to add ie: Default policy tag (DPT), Retention policy tags (RPTs), Personal tags?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Michael B. Smith

The ability to add tags is determined by whether the tags conflict or not within a single policy.

If tags conflict, Set-RetentionPolicy should give you an error.
ei00004

ASKER
Michael B. Smith was the only EE consultant that addressed/resolved my issue.