Active Directory client with powershell

2019-04-19

Add AD users from csv to group using powershell

A sample script for adding users (taken from a csv file) to an Active Directory group

$GroupName = "Qliksense_SI_Techedge"
$Users =  "e:\scripts\users.csv"

Import-module ActiveDirectory

$dc = Get-ADDomainController -DomainName mydomain.redaelli.org -Discover -NextClosestSite
$server = $dc.HostName[0]

get-content $Users | ForEach-Object {
  Get-ADUser -Server $server -LDAPFilter "(mail=$_)" } |
  Select-Object -ExpandProperty sAMAccountName |  ForEach-Object { Add-ADGroupMember -Server $server -Identity $GroupName -Member $_ }

Enter your instance's address


More posts like this

Active Directory authentication for PostgreSQL users

2020-10-12 | #active directory #ldap #postgres

It is easy, you just need to add to the configuration file /var/lib/postgresql/data/pg_hba.conf host all all 0.0.0.0/0 ldap ldapserver="myldapserver" ldapbasedn="OU=USERS,DC=group,DC=redaelli,DC=org" ldapbinddn="CN=matteo,OU=USERS,DC=group,DC=redaelli,DC=org" ldapbindpasswd="MySillyPwd" ldapsearchattribute="sAMAccountName" ldapscheme="ldaps" And inside your database yu need to create a role for the Active director users and then grant them to the required databases.

Continue reading 