-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAD_Operations_Script.ps1
More file actions
42 lines (41 loc) · 2.24 KB
/
Copy pathAD_Operations_Script.ps1
File metadata and controls
42 lines (41 loc) · 2.24 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
cls
write-host "------------------------"
write-host "AD User creation" -BackgroundColor DarkGreen
write-host "------------------------"
$FirstName = Read-host "Enter the FirstName?"
$LastName = Read-host "Enter the Last Name ?"
$Password = Read-host "Enter the Account Password?" -AsSecureString
$username = Read-host "Enter the UserName (FirstName.LastName)?"
$OU = read-host "Enter the OU(Employees/Engineering/IT/Sales)"
$OU = "OU=$OU,DC=Adatum,DC=com"
$Department = Read-Host "Enter the Department?"
$Title = Read-Host "Enter the Title?"
New-Aduser -Name $username -GivenName $FirstName -Surname $LastName `
-Department $Department -Title $Title -AccountPassword $Password `
-path $OU -ChangePasswordAtLogon $true -Enabled $True
Write-host "User Account $username has been created" -BackgroundColor DarkGreen
##########################################################################
write-host "------------------------"
write-host "AD Group creation" -BackgroundColor DarkGreen
write-host "------------------------"
$GName = Read-host "Enter the Group Name ?"
$GScope = Read-host "Enter the Scope of Group (DomainLocal/Global/Universal)?"
New-ADGroup -Name $GName -GroupScope $GScope
Write-host "Group $Gname has been created" -BackgroundColor DarkGreen
##########################################################################
write-host "------------------------"
write-host "Adding Member to a Group" -BackgroundColor DarkGreen
write-host "------------------------"
$Gname = Read-host "Enter the group Name ?"
$MemName = Read-host "Enter the Member Name ?"
Add-ADGroupMember $GName -Members $MemName
Write-host "User $MemName has been added to the group $GName" -BackgroundColor DarkGreen
##########################################################################
write-host "------------------------"
write-host "Removing Member to a Group" -BackgroundColor DarkGreen
write-host "------------------------"
$Gname = Read-host "Enter the group Name ?"
$MemName = Read-host "Enter the Member Name ?"
Remove-ADGroupMember -identity $GName -Members $MemName -Confirm:$false
Write-host "User $MemName has been removed to the group $GName" -BackgroundColor DarkGreen
############################################################################