Link to home
Start Free TrialLog in
Avatar of ei00004
ei00004Flag 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?

Avatar of Michael B. Smith
Michael B. Smith
Flag of United States of America image

Avatar of 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.
 
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

Avatar of 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.
I tested it before I sent it to you.

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

ASKER

Yes it does.
ASKER CERTIFIED SOLUTION
Avatar of Michael B. Smith
Michael B. Smith
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 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.
Yes, fixed above. I tried this with one through five tags and it works. It never replaces, it always appends.
Avatar of 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?
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.
Avatar of ei00004

ASKER

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