Created
November 17, 2016 03:05
-
-
Save RhysC/2b899333d622b2d91798269407960b19 to your computer and use it in GitHub Desktop.
Active directory snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# opens a GUI to manage users under the given account - fine for adding/upodate one or two accounts | |
runas /user:myDomain\myusername "C:\Windows\System32\rundll32.exe dsquery, OpenQueryWindow" | |
##POWERSHELL – to load the users, done from a server so it has the AD PS modules | |
import-module activedirectory | |
# basic search using ps filters | |
Get-ADUser -filter {GivenName -like "rickie"} | |
# get all the users in a group in normal looking string | |
Get-ADGroupMember Role-Department-Application-Admin | %{ Get-ADUser -Identity $_ } | %{ $_.GivenName + " " + $_.Surname} | |
##START – Bulk load the users | |
$userCsv = "C:\Users\myprofile\Documents\My_app_users.csv" | |
$adminCsv = "C:\Users\myprofile\Documents\My_app_admin.csv" | |
Import-Csv $userCsv | % { | |
Add-ADGroupMember -Identity Role-Department-Application-User -members $_.Username | |
} | |
Import-Csv $adminCsv | % { | |
Add-ADGroupMember -Identity Role-Department-Application-Admin -members $_.Username | |
} | |
#SHOW USERS IN GROUPS | |
get-adgroupmember -Identity "Role-Department-Application-User" | |
get-adgroupmember -Identity "Role-Department-Application-Admin" | |
##END – Bulk load the users |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment