ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Easy PowerShell AD Commands

    IT Discussion
    windows powershell active directory
    4
    4
    666
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by scottalanmiller

      Disable a user account:

      Disable-ADAccount username
      

      Enable a user account"

      Enable-ADAccount username
      

      Unlock a user account:

       Unlock-ADAccount username
      

      Delete a user account:

      Remove-ADUser username
      

      Find all empty groups:

      Get-adgroup -filter * | where {-Not ($_ | get-adgroupmember)} | Select Name
      

      Add a member to a group:

      Add-adgroupmember “groupname” –username
      

      Enumerate the members of a group:

      Get-ADGroupMember “groupname”
      

      See what groups a user account is a member of:

      Get-aduser username -property Memberof | Select -ExpandProperty memberOf
      

      Disable a computer account:

      Disable-ADAccount -Identity “computername“
      

      Find computers by type:

      Get-ADComputer -Filter * -Properties OperatingSystem | Select OperatingSystem -unique | Sort OperatingSystem
      

      Create an organizational unit:

      New-ADOrganizationalUnit -Name OUname -Path “dc=domainname,dc=com”
      

      Create a computer account:

      New-ADComputer -Name username -Path “ou=OUname,dc=DCname,dc=com”
      

      Create a user account:

      New-ADUser -Name username -Path “ou=OUname,dc=DCname,dc=com”
      
      1 Reply Last reply Reply Quote 5
      • ObsolesceO
        Obsolesce
        last edited by Obsolesce

        Also, in PowerShell, just type:

        Get-Command -Module ActiveDirectory

        Which should list all available AD commands.

        1 Reply Last reply Reply Quote 3
        • jmooreJ
          jmoore
          last edited by

          @scottalanmiller said in Easy PowerShell AD Commands:

          New-ADUser -Name username -Path “ou=OUname,dc=DCname,dc=com”

          Thanks, just added all that to my documentation for reference later

          1 Reply Last reply Reply Quote 0
          • EddieJenningsE
            EddieJennings
            last edited by

            One that I love

            Get-ADPrincipalGroupMembership -Identity SOMEUSERNAME | Select name
            

            List all of the groups in which the user is a member.

            1 Reply Last reply Reply Quote 3
            • 1 / 1
            • First post
              Last post