r3dzzz
r3dzzz

Reputation: 11

Powershell Outlook RecipientType not recognized

When running the following I get error :

RecipientType : The term 'RecipientType' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:89 + ... xyz -RecipientFilter ((((RecipientType -eq 'Us ... + ~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (RecipientType:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

Set-DynamicDistributionGroup -Identity 'xyz' -RecipientFilter ((((RecipientType -eq 'UserMailbox') -or (((RecipientType -eq 'MailUniversalDistributionGroup') -or (RecipientType -eq 'MailUniversalSecurityGroup') -or (RecipientType -eq 'MailNonUniversalGroup') -or (RecipientType -eq 'DynamicDistributionGroup'))) -or (((RecipientType -eq 'UserMailbox') -and (ResourceMetaData -like 'ResourceType:*') -and (ResourceSearchProperties -ne $null))))) -and (-not(Name -like 'SystemMailbox{*')) -and (-not(Name -like 'CAS_{*')) -and (-not(RecipientTypeDetailsValue -eq 'MailboxPlan')) -and (-not(RecipientTypeDetailsValue -eq 'DiscoveryMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'PublicFolderMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'ArbitrationMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'AuditLogMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'AuxAuditLogMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'SupervisoryReviewPolicyMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'GuestMailUser')) -and (-not(PrimarySmtpAddress -eq 'xyz')))

Any ideas?

Maybe a syntax issue I can't see

Upvotes: 0

Views: 2251

Answers (1)

Jawad
Jawad

Reputation: 11364

You are missing a double quote around your Filter. When you use RecipientFilterwithout quotes, RecipientType becomes a "cmdlet, function, script file, or operable program" that you'd expect powershell to know. Since it is specific to Set-DynamicDistributionGroup cmdlet, you have to send it as a string to this cmdlet as a value.

Set-DynamicDistributionGroup -Identity 'xyz' -RecipientFilter "((((RecipientType -eq 'UserMailbox') -or (((RecipientType -eq 'MailUniversalDistributionGroup') -or (RecipientType -eq 'MailUniversalSecurityGroup') -or (RecipientType -eq 'MailNonUniversalGroup') -or (RecipientType -eq 'DynamicDistributionGroup'))) -or (((RecipientType -eq 'UserMailbox') -and (ResourceMetaData -like 'ResourceType:*') -and (ResourceSearchProperties -ne $null))))) -and (-not(Name -like 'SystemMailbox{*')) -and (-not(Name -like 'CAS_{*')) -and (-not(RecipientTypeDetailsValue -eq 'MailboxPlan')) -and (-not(RecipientTypeDetailsValue -eq 'DiscoveryMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'PublicFolderMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'ArbitrationMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'AuditLogMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'AuxAuditLogMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'SupervisoryReviewPolicyMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'GuestMailUser')) -and (-not(PrimarySmtpAddress -eq 'xyz')))"

See documentation and examples by MS

Upvotes: 0

Related Questions