-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathPromotetoADAdmins.ps1
More file actions
26 lines (21 loc) · 877 Bytes
/
Copy pathPromotetoADAdmins.ps1
File metadata and controls
26 lines (21 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#Requires -Module ActiveDirectory
<#
.SYNOPSIS
Promotes users with specific titles to Domain Admins group.
.DESCRIPTION
Finds users with titles "IT Manager" or "Service Account" and adds them to the Domain Admins group.
Note: Be cautious with this script as it grants high-level privileges.
#>
Import-Module ActiveDirectory
# Get users with specific titles
$users = Get-ADUser -Filter { Title -eq "IT Manager" -or Title -eq "Service Account" }
if ($users) {
Write-Host "Found $($users.Count) user(s) to promote to Domain Admins:"
$users | Select-Object -ExpandProperty SamAccountName | Write-Host
# Add users to Domain Admins
Add-ADGroupMember -Identity "Domain Admins" -Members $users
Write-Host "Users successfully added to Domain Admins group."
}
else {
Write-Warning "No users found with titles 'IT Manager' or 'Service Account'."
}