In this blog post, I will show you how I create a new Active Directory user and add him to an Active Directory Group using PowerShell.
About the Script
After the script creates the user, the 3rd line will add the user to the Domain Admins group in Active Directory.
The last line will display all the group members of the Domain Admins group.
$pass = Read-Host "Enter password" -AsSecureString New-ADUser -Name "Ansible Service" -AccountPassword $pass -UserPrincipalName ansible -DisplayName "Ansible Service Account" -SamAccountName ansible Add-ADGroupMember -Identity "Domain admins" -Members ansible Get-ADGroupMember -Identity "domain admins" | Select-Object name