powershell script for deleting ad user

Home Forums Scripting General Scripting powershell script for deleting ad user

This topic contains 3 replies, has 3 voices, and was last updated by Avatar vickynet 7 months, 3 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • Avatar
    vickynet
    Participant
    #615033

    Hi,

    i have created powershell script for deleting bulk user in ad With CSV file but unfortunately it is not deleting my user list so could someone provide or help on this script.

     

    Thanks,

    Vignesh.

    Blood
    Blood
    Moderator
    #615079

    If you post your script someone may have time to look at it and make suggestions on how to get it working.

    Avatar
    wullieb1
    Moderator
    #615080

    Should be something as simple as

    #Import the AD module

    import-module ActiveDirectory

    #Get the contents of the relevant text file

    $users = (Get-Content -Path <PATH TO TEXT FILE>)

    # Loop through the users in the text file and remove them

    foreach($user in $users){

    Remove-ADUser -Identity $user

    }

    What are you using for the user list? According to the MS docs it needs to be one of these
    <ul style=”margin: 16px 0px 16px 38px; padding: 0px; box-sizing: inherit; color: #000000; font-family: ‘Segoe UI’, SegoeUI, ‘Segoe WP’, ‘Helvetica Neue’, Helvetica, Tahoma, Arial, sans-serif;”>
    <li style=”outline: 0px; box-sizing: inherit; list-style: disc outside none;”>A Distinguished name
    <li style=”outline: 0px; box-sizing: inherit; list-style: disc outside none;”>A GUID (objectGUID)
    <li class=”” style=”outline: 0px; box-sizing: inherit; list-style: disc outside none;”>A Security Identifier (objectSid)
    <li class=”” style=”outline: 0px; box-sizing: inherit; list-style: disc outside none;”>A SAM account name (sAMAccountName)

    https://docs.microsoft.com/en-us/powershell/module/addsadministration/remove-aduser?view=win10-ps

    Avatar
    vickynet
    Participant
    #615081

    Its working and its very simple to user this ,thanks lot.

     

     

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.