locked
accounts script RRS feed

  • Question

  • Guys,

    I need to create a powershell script to create users and add them to a specific group based on the last 3 characters of their username, is there a way to do this or use a group policy to enable this in the OU - is this a possibilty?

    fyi - I am already using a .csv file to specify the usernames.

    Thanks in advace.

    Nate

    Friday, November 8, 2019 8:47 AM

All replies

  • Look in the Gallery for scripts that can add users to groups based on a CSV,

    This forum does not write custom scripts on request.

    Please carefully review the following links to set your expectation for posting in technical forums.


    \_(ツ)_/

    Friday, November 8, 2019 8:54 AM
  • Hi Nate,

    You may find the matching functionality useful, if you extract the username, you can use the match function to check if something end with a certain set of letters.

    'BobHR' -match 'HR$'

    The dollar at the end is the signal for the end of the line, this would prevent accidental mismatches like HReed being included into the above example.

    Adding them to specific groups can be done through the following command.

    Add-ADGroupMember -Identity $Package -Members $Username

    Friday, November 8, 2019 1:56 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, December 6, 2019 9:41 AM