Using -like operator to select recipients for Dynamic Distribution Group

Dear Scriptor,
I got few thousand of data and would like to select recipient according to the CustomAttribute1.
Below is the sample data in my database.
Name: User1, CustomAttribute1: aa, bb, cc
Name: User2, CustomAttribute1: aa, bb
Name: User3, CustomAttribute1: bb, cc, dd
If I run the script as below,
New-DynamicDistributionGroup -name "myDyna.bb" -RecipientFilter {(CustomAttribute1 -like 'aa*')}
The return result is User1 and User2
When I run the script as below,
New-DynamicDistributionGroup -name "myDyna.bb" -RecipientFilter {(CustomAttribute1 -like 'bb*')}
No result returned
How can I overcome this issue?
Thanks.

Below are my sample data in O365.
Type
Identity
UserPrincipalName
DisplayName
FirstName
LastName
CustomAttribute1
Mailbox
77771111
[email protected]
7777 #1
7777
#1
a1, a2, a3
Mailbox
77772222
[email protected]
7777 #2
7777
#2
a1, a2
Mailbox
77773333
[email protected]
7777 #3
7777
#3
d4, a1
Mailbox
77774444
[email protected]
7777 #4
7777
#4
a2, e5, f6
Mailbox
77775555
[email protected]
7777 #5
7777
#5
g7, h8, i9
Mailbox
77776666
[email protected]
7777 #6
7777
#6
g8, i9, a3
I would like to create a DynamicDistributionList where CustomAttibute1 contain "a2".
The expecting result are 77771111, 77772222 and 77774444.
How can I write the script?
I am using Windows Azure Active Directory Module for Windows Powershell. I run the $PSVersionTable.PSVersion and it returned me Major=4, Minor=0, Build=-1, and Revision=-1.
This works for you case:
New-DynamicDistributionGroup -name "myDyna.bb" -RecipientFilter {CustomAttribute1 -like '*a2*'}
Do not use parens "()".
¯\_(ツ)_/¯

Similar Messages

  • Create Dynamic Distribution Groups Using Customized Filters

    I am looking to create a new Dynamic Distribution List. 
    Example: 
    DL - United States Users ([email protected]
    In AD we have the 'Office' field filled accordingly, which contains the attribute USCA___ or USIL (US,California,etc or US, Illinois,etc). 
    I was wanting to try creating these using this command/script; 
    New-DynamicDistributionGroup -Name "DL - United States Users" -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (Office -eq 'USCA*')(Office -eq 'USIL*')}
    Assistance here please: 
    1. What needs to be added in that line so that only certain users can email to it, rejecting all others (i.e. The Helpdesk or Corporate Communications)
    2. Is there a way to specify the SMTP address you want it to use? 
    3. Is there a way to have it only add mailboxes that are enabled in AD so disabled mailbox user accounts wont be added? 
    Thanks in advance everyone. 

    Hi,
    We can use the following command to create a Dynamic distribution group:
    New-DynamicDistributionGroup -Name "DL - United States Users" -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (Office -like
    'US, California' -or (Office -like 'US, Illinois')) -and (UserAccountControl -ne 'AccountDisabled, NormalAccount')}
    Then as what ED says, we can use the Set-DynamicDistributionGroup cmdlet with AcceptMessagesOnlyFrom or
    AcceptMessagesOnlyFromDLMembers parameter to specify certain users who can send email messages to this dynamic distribution group. And use PrimarySMTPAddress parameter to specify the primary return SMTP email address for the distribution group.
    Hope it helps.
    Thanks,
    Winnie Liang
    TechNet Community Support

  • Address List and RecipientFilter for dynamic distribution lists

    Hi guys
    I am trying to setup a Address List in exchange that contains dynamic distribution lists specified by the list name. So address List abc should contain dynamic distribution lists with list names "def" and "ghi" and "jkl"
    So far I have come up with below which displays all dynamic distribution lists. this works but how can I now filter further to specific lists?
    New-AddressList -Name abc -RecipientFilter {((Alias -ne $null) -and (ObjectClass -eq 'msexchdynamicdistributionlist'))}
    Example of what I am trying to acheive:
    New-AddressList -Name abc -RecipientFilter {((Alias -ne $null) -and ((ObjectClass -eq 'msexchdynamicdistributionlist') -and ('msexchdynamicdistributionlist' -eq 'def') -or ('msexchdynamicdistributionlist' -eq 'ghi') -or ('msexchdynamicdistributionlist' -eq
    'jkl'))}

    Hi,
    I have some tests in my environment using Exchange 2013. You can use the following cmdlet to create an address list that contains specified distribution group members.
    New-AddressList -Name test3 -RecipientFilter {((Alias -ne $null) -and (MemberOfGroup -eq 'CN=Sales,CN=Users,DC=contoso,DC=com'))}
    Note that it can't work for dynamic distribution group. In your case, I haven't found a parameter for dynamic distribution group in Exchange, your understanding will be appreciated.
    Hope my clarification can be helpful to you.
    Best regards,
    Amy Wang
    TechNet Community Support

  • Create dynamic distribution group from 2 or more OU ?

    How I can create Dynamic distribution group from 2 or more OU ?
    I tried modified solution from this post:
    http://social.technet.microsoft.com/Forums/office/en-US/11a338b9-dbca-4378-9cda-4590a5b8d0f7/exclude-specific-ou-or-user-from-dynamic-distribution-groups?forum=exchangesvrgenerallegacy
    but I'm not sure will this work.

    Hi,
    I have some tests in my environment using Exchange 2013. I use the following cmdlet to create a dynamic distribution group through multiple OUs, but it can't work as I expect.
    New-DynamicDistributionGroup -Name "Users with mobile phones" -Alias "usermobile" -RecipientFilter{(((recipienttype -eq 'usermailbox') -and (MobilePhone -ne $null) -and ((RecipientContainer -eq 'contoso.com/users') -or (RecipientContainer -eq 'contoso.com/test
    OU'))) )}
    Actually, we have a dedicated support team regarding the Microsoft Scripts. I recommend you ask your question on our Microsoft Scripts forum which is staffed by more experts specializing in this kind of problems. Thanks for your understanding.
    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?category=scripting
    Hope it helps.
    Best regards,
    Amy Wang
    TechNet Community Support

  • Using Like Operator For Parameter Fields

    Hi All,
    I have been figuring around this for few days, appreciated anyone know this could assit me
    I have a report which having a mobile no parameter fields.
    In my database, my mobile no was not a clean entry.
    For eg, a standard mobile number from Malaysia was 60126143331.
    1) 60 - indicate country code (MYS)
    2) 12 - indicate mobile operator
    3) 6143331 - indicate phone number
    Usually, peoples will entry it as 6012-6143331 or 012-6143331 or 0126143331 or 60126143331. In my CR report, i have a static mobile no selection. Currently, my filter selection will be as below:
    {pax.mobile_no} = {?p_mobileno}
    any possible to change it to like? meaning to say, if user enter 012-6143331 it will know that this was 6012-6143331 and the records will be selected into the report.
    Appreciated anyone know this could assits.
    Thanks in advance.
    Regards,
    CK

    Hi,
    tq for ur prompt reply.
    D value in my database r not fix, some mobile no could b 7 digits some could b up to 12 digits. But I jz want user to enter mobile no in 10 digits only. Example, mobile no in db wa 60126661233. However, user input in parameter selection could only 0126661233 without 6. In some situation if mobile no in db was 6012-6661233, user input willb only 0126661233 n this input will b match with data in db using like operator.
    I m wondering can this b archieve in cr?
    Tq
    regards,
    ck

  • Problem with LIKE operator in select query

    Hi,
    I want to compare one field using LIKE operator. But i m not able to do that.
    DATA: l_doctext type c value ''''.
    CONCATENATE l_doctext s_lbktxt-low '%' l_doctext INTO s_lbktxt-low.
    SELECT bukrs belnr gjahr blart bldat budat xblnr bktxt waers awtyp
                FROM bkpf INTO TABLE g_t_bkpf_labor
                FOR ALL ENTRIES IN g_t_bseg_unique
                WHERE bukrs = g_t_bseg_unique-bukrs
                AND belnr = g_t_bseg_unique-belnr
                AND gjahr = g_t_bseg_unique-gjahr
                AND blart = p_ldtype
                AND bktxt LIKE s_lbktxt-low.
    plz help. Am i dng something wrong.
    Value in s_lbktxt can be like 'TEA.....'

    hi ,
    check this program..
    tables:mara.
    data: begin of it_mara occurs 0,
          matnr like mara-matnr,
          meins like mara-meins ,
          mtart like mara-mtart,
          end of it_mara.
    select-options: s_matnr for mara-matnr.
          select matnr
                 meins
                 mtart
                 from mara
                 into table it_mara
                 where matnr like '%7'.
    sort it_mara by matnr.
    loop at it_mara.
    write:/ it_mara-matnr,
    it_mara-meins,
    it_mara-mtart.
    endloop.
    regards,
    venkat.

  • Problem in JDBC , when using LIKE operator. - VERY URGENT

    Problem in JDBC , when using LIKE operator.
    LINE 1 : String temp = "AA";
    LINE 2 : String query = "select * from emp where EMPNAME like '*temp*' ";
    LINE 3 : Staement st = con.createStaement();
    LINE 4 : ResultSet rs = st.executeQuery(query);
    '*' character is not getting evaluated. In MS ACCESS2000 only * is accepted instead of '%'. Moreover in MS ACCESS the like operator has to be used within double quotes as a String. whereas in other databases, it accepts single quotes as a String.
    Ex:
    In MS ACCESS
         select * from emp where ename like "*aa*";
    Other Databases
         select * from emp where ename like '%aa%';
    In my situation iam passing a Variable inside a like operator and '*' is used.
    For the above Scenario, Please help me out.
    If possible Kindly let me know the exact Syntax.
    Please give me the answer as LINE1,LINE2,LINE3,LINE4,
    I have verified in JDBC Spec also, it has been specified to use escape sequence.that too did not work.
    Due to this, My project is in hold for about 4 days. I could not find a suitable solution.
    Please help me out.

    I made a LIKE clause work with M$ Access, using PreparedStatement and the % wildcard:
                escapeStr                   = "%";
                String sql                  = "SELECT USERNAME, PASSWORD FROM USERS WHERE USERNAME LIKE ?";
                PreparedStatement statement = connection.prepareStatement(sql);
                statement.setString(1, ("user" + escapeStr));
                ResultSet resultSet         = statement.executeQuery();
                while (resultSet.next())
                    System.out.println("username: " + resultSet.getObject("USERNAME") + " password: " + resultSet.getObject("PASSWORD"));

  • How to use LIKE operator in plsql

    Hi
    I wanted to select certain rows using like operator in plsql(Input should be given by the user). I have given my experiment here .I couldn't get any result.
    As per sql syntax while using LIKE operator we should give search criteria within single quote.where as in plsql if we give within single quote its takes as string so no output is comming.what is solution ? How to use like operator in plsql?
    sql syntax
    SQL>SELECT customer_name FROM customer_header
    WHERE customer_name LIKE 'B%' ; customer_name
    Bala murali
    Babu
    Basker
    plsql syntax
    PROCEDURE pro_custheader_like ( v_cname IN varchar2
         ,answer OUT type_refcur_customer) IS
         BEGIN
         OPEN answer FOR
         SELECT customer_name FROM customer_header
              WHERE customer_name LIKE ( ' v_cname ' );
    END pro_custheader_like;
    execution command
    sql>variable answer refcursor;
    sql>set serveroutput on
    sql>exec package_name.pro_custheader_like( 'R',:answer);
    plsql successfully completed
    sql>print :answer
    no row selected
    by
    balamuralikrishnan.s

    plsql syntax
    PROCEDURE pro_custheader_like ( v_cname IN
    varchar2
    ,answer OUT
    type_refcur_customer) IS
    N
         OPEN answer FOR
         SELECT customer_name FROM customer_header
    WHERE customer_name LIKE ( v_cname );
    END pro_custheader_like;
    Try it without any quotes. And, let us know your feedback.
    Regards.
    Satyaki De.
    Message was edited by:
    Satyaki_De

  • How to pass variable into lov sql query using like operator

    hi.
    i want to use a lov where i want to pass a variable using like operator.
    my query is
    select empno,name from table where empno like ':ed%';
    my empno is A001 TO A199 AND B001 TO B199 so i want show either A% or B% empno
    how can i do this ?
    reagrds

    kindly press Shift+F1 at a time you face this error to see the exact Oracle error message.
    and provide us with that detail
    and its better if you start new topic for that error... because that will be new error,,,
    -- Aamir Arif
    Edited by: Aamiz on Apr 7, 2010 12:27 PM

  • How tio use like operator in textitem to get the name

    Oracle forms6i
    Hai All
    I have created an form to create an hierarchy list. I that I had an Text_item how can i use like operator to get the name to select. which trigger i need to use. when i select the name i need to get his employee code and other details
    Thanks In Advance
    Srikkanth.M

    A is the head of Dept 10 and three person are under A namelyHow will you know that B, C and D are under A is there any parent child relationship between Leader and Employee code? If yes, Then you can create the relationship between blocks no need to set where_clause programatically. So, relationship can be like...
    leader_block.emp_code = emp_block.leader_code
    AND leader_blokc.dep_code = emp_block.dep_codeSo, when you will query data in LEADER block it will show employees which are under LEADER which you queried in LEADER block.
    Or if there is no relationship then how will you know that which employee under which leader?
    b 002 10 1
    c 003 10 1
    d 004 10 1
    When i enter the name of head corresponding other members in the department will need to display in the
    Tabular format Or if you want to query the records only for department relation. Then as you said you create two blocks then create create the relationship using dep_code between those blocks.
    like...
    leader.dep_code = emp_block.dep_code-Ammad

  • Get Result using LIKE operator

    Hi All,
    I am bit confused as to how to get this output using like operator :
    select * from table1 where name like 'P&C%';
    Here , since '&' is there , sql is prompting me to enter a value for C instead of giving output. I tried using escape but it is not working.
    Can anybody tell me how to overcome this problem..?
    Thanx.

    Alright,
    Here you go. In 'SQL Editor' in PL/SQL Developer:
    Pulled this off the PL/SQL Developer Manual:
    Escape character
    If you wish to use an ampersand in the SQL text that should not be interpreted as a substitution variable,
    use a double ampersand instead. The following example will retrieve all employees from the ‘R&D’
    department:
    select * from emp
    where emp.deptno in (select dept.deptno from dept
    where dname = 'R&&D')
    order by empno desc
    If the text 'R&D' had been used instead, you would have been prompted for the D variable.

  • MailTips for Dynamic Distribution Lists - wrong number of recipients

    We use Exchange 2013 and Outlook 2013. We have a Dynamic Distribution List ([email protected]) configured on Exchange. It contains 75 users, I confirmed it using below cmdlets in Exchange management shell
    $all = Get-DynamicDistributionGroup [email protected]
    Get-Recipient -RecipientPreviewFilter $all.recipientfilter
    When I use Outlook to create a new email to [email protected] there is a MailTip displayed mention about 87 of recipients, it should be 75 users. 
    Settings on our Exchange servers are as below:
    [PS] C:\Windows\system32>Get-OrganizationConfig | fl *mailtip*
    MailTipsAllTipsEnabled                : True
    MailTipsExternalRecipientsTipsEnabled : False
    MailTipsGroupMetricsEnabled           : True
    MailTipsLargeAudienceThreshold        : 25
    MailTipsMailboxSourcedTipsEnabled     : True
    Any idea how to troubleshoot it?

    In Active Directory attributes for this group are as below
    msExchGroupMemberCount =
    87msExchGroupExternalMemberCount
    = 0 
    Regarding
    files under %ExchangeInstallPath%GroupMetrics there is only cookie file modified yesterday and
    it contains as below:
    DC=domain,DC=com;12/28/2014 13:11:15;05/14/2013 20:02:24
    Just created new dynamic distribution group with the same filter as for group all (for test purpose). There is no MailTip for this new group now. Is it possible to force \ speed up group metrics generation?

  • How to use like operator in loop

    Hi I am trying to use like operation in loop condition. the code is as follows:
    loop at lt_mara into l_mara where l_mara like '%XXX'.
    endloop
    when i have the like operator like above its giving me an error that i cannot use like operator. Is there anyway that i can use like operation in loop at condition,
    Thanks in advance

    using the ranges with CP option we can do that..
    Populate the ranges mentioned below..
    data: r_matnr type range of matnr,
            w_matnr like line of r_matnr.
    w_matnr-low = '%XXX'.
    w_matnr-sign = 'I'.
    w_matnr-option = 'CP'.
    append w_matnr to r_matnr.
    loop at lt_mara into l_mara where matnr in r_matnr.
    endloop
    Regards
    Vijay Babu Dudla

  • Selection variant for cost element GROUPS

    Community!
    Is there a way to create a selection variant for cost element groups? Through customizing I can only create them for cost elements but not for groups!
    Thanks,
    Bjoern

    Ashok,
    thanks for your reply but I am looking for a way to create a variant for groups!!!!!
    The help just depicts how to create variants for cost elements. You actually do have the feature to display all cost elements from <u>one</u> group within the collective processing but I would need to select many different groups, which is just not possible.
    Therefore I would like to create a variant of cost element <b>groups</b>!!!!!
    Regards,
    bjoern

  • Edit existing Dynamic Distribution Group

    I'm running Exchange 2007 RTM
    I have an existing Dynamic Distribution Group "All Staff" - here's the filter taken from 'Properties'
    (&(!cn=SystemMailbox{*})(&(&(& (mailnickname=*) (| (&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*))) )))))
    My question is it possible to EDIT the group to exclude a user? If so how?

    You can edit the dynamic distribution list in EMS and add to the recipient an exclusion based on a value of an attribute (for example a CustomAttribute). 
    first get your current recipient filter with 
    Get-DynamicDistributionGroup dl_dyn_test | fl recipientfilter
    in this example the filter is set to include everything with a CustomAttribute11 value of "plop":
    ((((((((CustomAttribute11 -eq 'plop') -and (Alias -
    ne $null))) -and (-not(Name -like 'SystemMailbox{*'
    )))) -and (-not(Name -like 'CAS_{*')))) -and (-not(
    Name -like 'SystemMailbox{*')) -and (-not(Name -lik
    e 'CAS_{*')))
    lets say we want to exclude the recipients with a CustomAttribute12 value "flop"; we would have to add "-and (-not(CustomAttribute12 -eq 'flop'))" to our filter, making it:
    ((((((((((((((CustomAttribute11 -eq 'plop') -an
    d (-not(CustomAttribute12 -eq 'flop')))) -and (
    Alias -ne $null))) -and (-not(Name -like 'Syste
    mMailbox{*')))) -and (-not(Name -like 'CAS_{*')
    ))) -and (-not(Name -like 'SystemMailbox{*'))))
     -and (-not(Name -like 'CAS_{*')))) -and (-not(
    Name -like 'SystemMailbox{*')) -and (-not(Name
    -like 'CAS_{*')))
    We can write this back to our existing DynDL with the following command:
    Get-DynamicDistributionGroup dl_dyn_test | Set-DynamicDistributionGroup -recipientfilter {<recipientfilter>}
    !!! do not forget the "{}" around the filter value !!!
    So our command becomes: 
    Get-DynamicDistributionGroup dl_dyn_test | Set-DynamicDistributionGroup -recipientfilter {((((((((CustomAttribute11 -eq 'plop') -and (-not(CustomAttribute12 -eq 'flop')) -and (Alias -ne $null))) -and (-not(Name -like 'SystemMailbox{*')))) -and (-not(Name -like 'CAS_{*')))) -and (-not(Name -like 'SystemMailbox{*')) -and (-not(Name -like 'CAS_{*')))}
    After this executes you can use the previous command again to read the value of recipientFilter attribute and verify the change. You can check that the DynDL is working properly by clicking  on the Preview button on the Filter tab in the DynDL properties
    window in EMC, and verifyng that the excluded recipients are not present in the list.

Maybe you are looking for

  • How do I disable Firefox from opening at login

    I unclick the option that tells firefox to NOT open at login, but when I log back on, it opens again and shows the 'open at login' option as 'clicked' How do I disable? thx

  • URL Decode SSO Token Flag Property IIS 6.0

    I have the Policy Agent 2.2 for IIS 6.0 to install. I have been installing the agents before and all of them had the option of URL Decode SSO Token Flag Property (com.sun.identity.agents.config.sso.decode), but I can not find it here. Has it been dis

  • List of Executed SAPScripts

    Is there any method available to identify which SAPScripts have been executed in a system?  For ABAPs you can do an analysis of ST03 data to know which programs have been executed.  I am looking for a similar process for SAPScripts.  We need to make

  • Simultaneous volume failing

    Hi, I have 2 Seagate FreeAgent GoFlex 1.5TBs. Recently, one of the partitions on one (I'll refer to it as the first one) won't show up in Finder, but still would show up in Disk Utility (although grayed out). Therefore, I hit "Repair Disk", and it sh

  • Sigma 50mm F1.4 DG HSM, Nikon mount lens correction =- not supported?

    Lens database states that this lens is supported in Lightroom 5.5. I'm running version 5.7 and the lens profile does not seem to be available. - hat do I need to do?