How to move members of a certain OU from one security group to distribution group?

Looking for a powershell script that could move members from a certain OU that are members of a certain security group to a distribution group. Anyone point me in the right direction?

It is easy to determine the members of a group. My concern is that once you know the users, it can be tricky to determine their parent OU in a script. There are ways to parse the user distinguishedName, but some are unreliable (the names of OU's, and even
DC components, can include commas, for example). The most reliable method would be to bind to the user object with the [ADSI] accelerator and invoke the Parent method, but even then you must parse the result since it will be an ADsPath rather than a DN.
My approach would be to use Get-ADUser to find all users in a specified OU that are direct members of a specified group. Even here I assume you are only concerned with users (not contacts or groups or computers). I also must assume that no users have the
group specified as their "primary" group. The code I would suggest to  retrieve all users in an OU that are members of a group:
Get-ADUser -SearchBase "ou=Sales,ou=West,dc=MyDomain,dc=com" -LDAPFilter "(memberOf=cn=MyGroup,ou=West,dc=MyDomain,dc=com)"
This does not find users in the OU that are members of the group due to group nesting. However, if that matters, it can be handled using another LDAP syntax filter. In that case use:
Get-ADUser -SearchBase "ou=Sales,ou=West,dc=MyDomain,dc=com" -LDAPFilter "(memberOf:1.2.840.113556.1.4.1941:=cn=MyGroup,ou=West,dc=MyDomain,dc=com)"
The "1.2.840.113556.1.4.1941" part is a special chain matching rule that results in a recursive match to handle group nesting. You can also devise a filter to include membership as the "primary" group. You could even use Get-ADObject
instead  of Get-ADUser if you need to include contacts (or computers or groups), but I assume that is unnecessary.
The next steps, to remove from one group and add to another, would follow.
Richard Mueller - MVP Directory Services

Similar Messages

  • How to move an existing Application/Package Deployment from one collection to another

    We'd like to move an Application Deployment from one collection of devices to another. Instead of just creating a new deployment (which would make the app try to reinstall) we'd like to move the existing deployment.
    Any way to do this with PowerShell?

    Creating a new deployment won't make an app try to reinstall at all. That's the whole point of the Detection method.
    For packages, clients keep track of what they've run before so a new deployment won't cause it to run again unless the program is set for it to run again.
    Ultimately, you cannot change the collection targeted by a deployment as this violates a f underlying assumptions and messes up compliance/reporting for that deployment. You need to create a new deployment which as pointed out has no down-side.
    Jason | http://blog.configmgrftw.com

  • How to move the contents of an itab from one class to another...

    Hello Experts,
    How can I move the contents of an internal table for a given class to another class.
    I want to transfer the contents of my internal table lt_vbak to another class
    which is lcl_get_docflow. Below is my code:
    REPORT  zsd_orderstage
            NO STANDARD PAGE HEADING.
    * Data Dictionary Table/s                      *
    TABLES: vbak.
    * Global Structure/s                           *
    TYPES: BEGIN OF t_output,
            salesgroup    type vbak-vkgrp,
            salesorder    TYPE vbak-vbeln,
            custcode      TYPE vbak-kunnr,
            shipto        TYPE likp-kunnr,
            creation_date TYPE vbak-erdat,
            created_by    TYPE vbak-ernam,
            delorder      TYPE likp-vbeln,
            invnumber     TYPE vbrk-vbeln,
           END OF t_output.
    * Global Internal Table/s                      *
    DATA: gt_output TYPE STANDARD TABLE OF t_output.
    * SELECTION-SCREEN                             *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS:     p_kunnr TYPE vbak-kunnr OBLIGATORY.
    SELECT-OPTIONS: s_group for vbak-vkgrp,
                    s_auart FOR vbak-auart,
                    s_erdat FOR vbak-erdat  OBLIGATORY,
                    s_ernam FOR vbak-ernam.
    SELECTION-SCREEN END OF BLOCK b1.
    *       CLASS lcl_main DEFINITION
    CLASS lcl_main DEFINITION ABSTRACT.
      PUBLIC SECTION.
        TYPES: BEGIN OF t_vbak,
              vbeln TYPE vbak-vbeln,
              erdat TYPE vbak-erdat,
              ernam TYPE vbak-ernam,
              auart TYPE vbak-auart,
              kunnr TYPE vbak-kunnr,
              vkgrp type vbak-vkgrp,
             END OF t_vbak.
        TYPES: BEGIN OF t_vbfa,
                vbelv   TYPE vbfa-vbelv,
                vbeln   TYPE vbfa-vbeln,
                vbtyp_n TYPE vbfa-vbtyp_n,
               END OF t_vbfa.
        TYPES: BEGIN OF t_likp,
                vbeln TYPE likp-vbeln,
                kunnr TYPE likp-kunnr,
               END OF t_likp.
        TYPES: BEGIN OF t_vbrk,
                vbeln TYPE vbrk-vbeln,
               END OF t_vbrk.
        DATA: gt_vbfa     TYPE STANDARD TABLE OF t_vbfa,
              gt_likp     TYPE HASHED TABLE OF t_likp
                          WITH UNIQUE KEY vbeln,
              gt_vbrk     TYPE HASHED TABLE OF t_vbrk
                          WITH UNIQUE KEY vbeln,
              gt_delivery TYPE STANDARD TABLE OF t_vbfa,
              gt_invoice  TYPE STANDARD TABLE OF t_vbfa.
    ENDCLASS.                    "lcl_main DEFINITION
    *       CLASS lcl_get_so DEFINITION
    CLASS lcl_get_so DEFINITION INHERITING FROM lcl_main.
      PUBLIC SECTION.
        DATA: lt_vbak TYPE STANDARD TABLE OF t_vbak.
        METHODS: get_sales_orders
                    RETURNING
                       value(re_vbak) TYPE t_vbak.
    ENDCLASS.                    "lcl_get_so DEFINITION
    *       CLASS lcl_get_so IMPLEMENTATION
    CLASS lcl_get_so IMPLEMENTATION.
      METHOD get_sales_orders.
        SELECT vbeln erdat ernam auart kunnr vkgrp
          FROM vbak
          INTO TABLE lt_vbak
         WHERE erdat IN s_erdat
           AND ernam IN s_ernam
           AND auart IN s_auart
           AND kunnr = p_kunnr.
      ENDMETHOD.                    "get_sales_orders
    ENDCLASS.                    "lcl_get_so IMPLEMENTATION
    *       CLASS lcl_get_docflow DEFINITION
    CLASS lcl_get_docflow DEFINITION INHERITING FROM lcl_main.
      PUBLIC SECTION.
        DATA: lt_vbfa TYPE STANDARD TABLE OF t_vbfa.
        METHODS: get_subsequent_docs
                    IMPORTING
                       value(im_vbak) TYPE t_vbak
                    EXPORTING
                       ex_vbfa TYPE t_vbfa.
    ENDCLASS.                    "get_docflow  INHERITING FRO
    *       CLASS lcl_get_docflow IMPLEMENTATION
    CLASS lcl_get_docflow IMPLEMENTATION.
      METHOD get_subsequent_docs.
      ENDMETHOD.                    "get_subsequent_docs
    ENDCLASS.                    "get_docflow IMPLEMENTATION
    * Global Internal Table/s                      *
    START-OF-SELECTION.
      DATA: o_get_so      TYPE REF TO lcl_get_so,
            o_get_docflow TYPE REF TO lcl_get_docflow.
      CREATE OBJECT: o_get_so,
                     o_get_docflow.
      CALL METHOD o_get_so->get_sales_orders.
    What I want is to pass the records of lt_vbak to method get_subsequent_docs. How do I do this guys?Thank you and take care!

    .

  • How to move imovie '08 projects and events from one macbook to another

    Hi,
    I need to import my movies via firewire, but can only do it through my brother's macbook, as my new macbook does not have firewire.
    Therefore, I imported 100 GB worth of movies onto his computer, then transferred the iMovie Events and iMovie Projects folders onto a hard drive, then transferred them from the hard drive to MY macbook. Now they are sitting on the desk top.
    How do I get them into iMovie on my macbook, now that I have transferred the files from my brother's macbook onto my macbook's desktop?
    Thanks!

    I guess I just needed to drag my events into my user folder ---> movie events, and then when I launched iMovie, it found them.

  • How to move the data of a table from sqlplus to XML file

    Hi,
    Could you pls guide me how to move the data of a table from sqlplus to XML file.
    i want to do it from sqlplus rather than toad.pls help
    Thanks

    Oh..I'm in 9i.
    Try this out..and let me know.
    DECLARE
    CTX DBMS_XMLGEN.CTXHANDLE ;
    XML CLOB ;
    F UTL_FILE.FILE_TYPE;
    XMLC VARCHAR2(32767);
    BEGIN
    CTX := DBMS_XMLGEN.NEWCONTEXT('SELECT * FROM department1 ') ;
    XML := DBMS_XMLGEN.GETXML(CTX) ;
    XMLC:=TO_CHAR(XML);
    SHOW_ENVELOPE(XMLC);
    F := UTL_FILE.FOPEN('ATTACH_FILES','DEPT.XML', 'W');
    UTL_FILE.PUT_LINE(F,XML);
    UTL_FILE.FCLOSE(F);
    END ;
    Good luck!!!
    Bhagat
    null                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to move Tablespace from One disk group to another disk group in RAC

    Hi All,
    I have 11gR2 RAC env on Linux.
    As ofnow I have problem with disk group. I have 3 disk group which is almost full - 98%. I have added one NEW disk group and want to move some of the Tablespace(TBS) from OLD disk group to NEW diskgroup and make some free space in OLD disk group.
    Can any one suggest me how to move TBS from one disk group to another disk grup without shutting down the instance.
    DB is in Noarchive mode.
    Thanks...

    user12039625 wrote:
    Hi Helios,
    Thanks for doc id but I am looking for noarchive mode solution. becaues I got ORA-
    "ORA-01145: offline immediate disallowed unless media recovery enabled " when run alter database datafile '...' offline.
    Hence I am trying something and findout below steps but not sure how useful it is:
    1- put tablespace offine
    2- Copy the file to new diskgroup using Either RMAN or DBMS_FILE_TRANSFER.
    3- Rename the file to point to new location.
    4- Recover the file.
    5- Bring the file online.
    I had move 240M TBS from OLE to NEW.
    These steps run successfully so I think this is valid for noarchive mode.Hence want to confirm..so inform me please.
    Thanks :)I have doubt in my mind:
    1. You database is in noarchivelog mode
    2. You're taking tablespace offline
    3. Suppose you're moving a file of size 10GB(or any larger filesize) to another disk group
    4. Now after moving the file, you're trying to bring the tablespace online............NOW
    tablespace will need recovery. if the required data is inside the SGA then it is ok. But if the data has been flushed, then?
    if step 2 and 3 has taken significant time, then most probably you'll not be able to bring that tablespace online.
    Regards,
    S.K.

  • How can I move CC to a new PC, from one I am returning to our asset team?

    I have CC installed on two PCs. So how can I move CC to a new PC, from one I am returning to our asset team?
    Howard

    You only need to sign out of it on the machine you wish to not use it on anymore.  After that, if you choose to you can uninstall it, but it is not necessary in terms of the software... maybe your asset team has issue with it remaining though.
    To get it on the new machine just install the same way you did for any others... install the Cloud manager, sign in, install the applications.

  • How can I move my iPad's iTunes backup from one user to another?

    Is it possible to move my iPad's iTunes backup from one user to another, so as to change which user the iPad is syncing to without deleting any app data? Currently the iPad is synced to one user on my iMac, and I would like to transfer it so that it will sync with a different user on the same iMac (using iTunes, of course). I'd like to replace content from the old user's iTunes library with my user (eg. music, movies), but I don't want to loose app data in the process if I can avoid it.
    I have tried to use the pathway /Library/Application Support/MobileSync/Backup but my iMac doesn't seem to have a MoblieSync folder. I wouldn't know what to do with the backup anyway though.
    Can anyone help me or is this request too complicated, difficult, or impossible? Thanks for your help!

    The Apple Document covers this. See the footnotes of my google docs
    I've done this, it is easy, but takes time and patience.
    On the existing mac with OSX and Configurator:
    ========================================
    - run disk utility and verify your disks are ok, a must
    - make note of the user logged in when using configurator  such as "bob"
    - connect a new or newly reformatted USB formatted for Apple
    - run time machine and backup to the USB
    - Take the mac off the network,
    - Buy a new mac
    - setup the mac with a new logon account like Paul or  "bob2"   do not use BOB !!
    - finish the new purchase setup, get to your desktop
    - now run the migraiton assistant  moving bob from the USB to the new mac
    - reboot, logon as bob, launch configurator and connect just one ipad.  Test
    https://docs.google.com/document/d/1SMBgyzONxcx6_FswgkW9XYLpA4oCt_2y1uw9ceMZ9F4/ edit?usp=sharing

  • Best way to move redo log from one disk group to another in ASM?

    Hi All,
    Our db is 10.2.0.3 RAC db. And database servers are window 2003 server.
    We need to move more than 50 redo logs (some are regular and some are standby) which are not redundant from one disk group to another. Say we need to move from disk group 1 to 2. Here are the options we are thinking about but not sure which one is the best from easiness and safety prospective.
    Thank you very much for your help in advance.
    Shirley
    Option 1:
    1)     shutdown immediate
    2)     copy log files from disk group 1 to disk group2 using RMAN (need to research on this)
    3)     startup mount
    4)     alter database rename file ….
    5)     Open database open
    6)     delete the redo files from disk group 1 in ASM (how?)
    Option 2:
    1)     create a set of redo log groups in disk group 2
    2)     drop the redo log groups in disk group 1 when they are inactive and have been archived
    3)     delete the redo files associated with those dropped groups from disk group 1 (how?) (According to Oracle menu: when you drop the redo log group the operating system files are not deleted and you need to manually delete those files)
    Option 3:
    1)     create a set of redo members in disk group 2 for each redo log group in disk group 1
    2)     drop the redo log memebers in disk group 1
    3)     delete the redo files from disk group 1 associated with the dropped members

    Absolutely not, they are not even remotely similar concepts.
    OMF: Oracle Managed Files. It is an RDMBS feature, no matter what your storage technology is, Oracle will take care of file naming and location, you only have to define the size of a file, and in the case of a tablespace on an OMF DB Configuration you only need to issue a command similar to this:
    CREATE TABLESPACE <TSName>; So the OMF environment creates an autoextensible datafile at the predefined location with 100M by default as its initial size.
    On ASM it should only be required to specify '+DGroupName' as the datafile or redo log file argument so it can be fully managed by ASM.
    EMC. http://www.emc.com No further commens on it.
    ~ Madrid
    http://hrivera99.blogspot.com

  • HT5787 How do I transfer an Itunes gift card from one account to another ? I do not remember the password or the security questions.

    How do I transfer an Itunes gift card from one account to another ? I do not remember my password or know my security questions.

    You can't do it yourself. If you've just redeemed it and not spent any of it then you could try contacting iTunes Support and see if they can move it the other account : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • Can I sync certain itmes from one itunes account and certain items from another itunes account on the same ipad?

    I was wondering if an individual would be able to sync certain items from one itunes account and and items from a different itunes account to the same ipad?

    You move the song files to /Users/Shared/ and then into iTunes from the other Mac OS X user account.
    If you want to change the iTunes Store account associated with them, you need to redownload them from that account.
    (60812)

  • How to carry over my Elements Organizer catalog from one version to another

    How do I copy all my photos along with tags and ratings from Elements 8 to Elements 11
    Message title was edited by: Brett N

    If you are installing Elements 11 on the same machine , install Elements 11 and just convert your catalog from catalog manager.
    else if you want to move the content make the Backup from one system and restore it on new machine file >> backup catalog and restore catalog.

  • How do i migrate all my imovie projects from one computer to another

    how do i migrate all my imovie projects from one computer to another

    You need to attach the computers to one another say with a firewire cable? Or use an external hard drive to copy the Events/Projects and then move the hard drive to the other computer. Are you able to do either one of these first?

  • How can I transfer my app store purchases from one account to another?

    Can I transfer my apps to a new iTunes account from my old one? How?
    Thanks.

    No, you cannot transfer apps from one account to another iTunes account. Apps are DRM protected and forever tied to the account used to originally obtain them.

  • How do i change my ipod touch permanently from one apple id account to a new one

    How do i permanently change my ipod touch from one apple id to a new one with my new ipad and have the same apps etc on both.
    Thanks.

    - Go to Settings>iTunes and App Stores and sign out and sign in with other ID. To update apps purchased with the first account you will have to log into that account.
    - iTunes purchases are permanently locked to the account that purchased the.
    - There are also other items on the device that are associated with the account such as iCloud account and where you can be reached for Messages and FaceTime.

Maybe you are looking for

  • Nested IF Statement in WHERE clause...

    Here is a really abridged sample of my package. I need to ensure that if a salesrep has a status of 'I' (for "inactive") that the next salesrep with a status of 'A' (for "active") will be selected in its place. Should I include a nested loop within t

  • SSRS 2008 R2 matrix layout issue

    Hi, I am working on a report where I have to report total number of tickets resolved per Resource in a week and I get the total number of tickets from a different table and issues resolved from another and most of the aggregation I do it in my datase

  • ACPI AC adapter plugging in/off not recognized

    Hi! I got problem with events handling in acpi, it does not recognize any action connected with ac adapter plugging in/off. here is tail -f /var/log/messages.log: Jan 31 22:32:29 localhost logger: ACPI action undefined: PNP0C0A:00 Jan 31 22:32:41 loc

  • Grey Background of Arcobat program conflicts with Grey PDFs

    I have a client who use a grey background & border on their ads. This grey background is almost exactly the same colour as the background colour of Adobe Acrobat Professional - so when I view pdf's I cannot see where the pdf page ends or starts as it

  • My igoogle homepage does not fit properly on my screen

    I use igoogle homepage and the layout does not fit. It is minimized currently to get the "firefox tab" at the top but the left side is only half visible.