Scripts related to Active Directory module
The following PowerShell script can be used to view the reporting CXO of a list of users with UserPrincipalName (UPN) in Active Directory. You can download the script from Github.
PowerShell.exe -ExecutionPolicy Bypass -File .\ReportingCXO.ps1
# Define the CEO's name
$CEOName = "Yara Ayurvie"
# Defind the User List.
$UserList = '.\Users.csv'
By providing,
- CEOName
- UserList with UserPrincipalName (UPN). Sample CSV file: Users.csv
it will export CSV file with user email address and corresponding CXO.
Using PowerShell and Active Directory, it determines if users directly report to the CEO or traverse the managerial hierarchy. I have use this UserList for the demonstration.
The following PowerShell script can be used to view the reporting Manager (CXO, CXO-1, CXO-2 etc) of a set of userswith UserPrincipalName (UPN) in Active Directory. You can download the script from Github.
PowerShell.exe -ExecutionPolicy Bypass -File .\ReportingManager.ps1
# Define the Direct Reports - Names of CXO, CXO-1, CXO-2
$DirectReports = @("Yara Ayurvie", "Ama Fernando", "Hansani Perera", "Jon Secada", "Dilith Achalan", "Kotlin Segev")
# Defind the User List.
$UserList = '.\Users.csv'
By providing,
- DirectReports
- UserList with UserPrincipalName (UPN). Sample CSV file: Users.csv
it will export CSV file with user email address and corresponding Direct Reports - Names of CXO, CXO-1, CXO-2.
The following PowerShell script can be used to view the members of an Active Directory group. You can download the script from Github.
PowerShell.exe -ExecutionPolicy Bypass -File .\ViewMembers.ps1 -GroupName SystemAdmin
By providing group name argument -GroupName [group name], it will export a CSV file with group members of that specific group.
The following PowerShell script can be used to add the members to an Active Directory group. You can download the script from Github.
PowerShell.exe -ExecutionPolicy Bypass -File .\AddMembers.ps1 -GroupName SystemAdmin -FileName .\GroupMembers.csv
By providing group name argument -GroupName [group name] and -FileName [file name], it will add the group members to that specific group.
The following PowerShell script can be used to remove the members to an Active Directory group. You can download the script from Github.
PowerShell.exe -ExecutionPolicy Bypass -File .\RemoveMembers.ps1 -GroupName SystemAdmin -FileName .\GroupMembers.csv
By providing group name argument -GroupName [group name] and -FileName [file name], it will remove the group members from that specific group.
