Question

Create 3 PowerShell Scripts. The first 2 are worth 2 points each. The 3rd one is extra credit, wo...

Create 3 PowerShell Scripts. The first 2 are worth 2 points each. The 3rd one is extra credit, worth 1 point.

Script 1: Add/Remove Users
Fields: Username, FirstName, LastName, Description, OUPath, Password, Action (Add | Remove)

Script 2: Create Security Groups
Fields: Name, Description, OUPath, Scope (DomainLocal | Global | Universal), Category (Distribution | Security)

Script 3: Modify Security Group Membership
Fields: GroupName, Username, Action (Add | Remove)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question 1

Add User

Import-Module activedirectory
  
$diiffsu = Import-csv C:\test.csv

foreach ($User in $diiffsu)
{
      
   $uname    = $User.username
   $paswd    = $User.password
   $fname    = $User.firstname
   $lname    = $User.lastname
   $OU        = $User.oupath
   $description = $User.department


   if (Get-ADUser -F {SamAccountName -eq $uname})
   {
      
       Write-Warning "User Already Exist"
   }
   else
   {

       New-ADUser `
-SamAccountName $uname `
-UserPrincipalName "[email protected]" `
-Name "$fname $lname" `

-GivenName $fname `
-Surname $lname `
-Enabled $True `
-DisplayName "$lname, $fname" `
-Path $OU `
   -Description $description
-AccountPassword (convertto-securestring $paswd -AsPlainText -Force) -ChangePasswordAtLogon $True
  
   }
}

Remove User

remove-aduser $username -confirm:$false

Question 2

New-ADGroup -Name $grpname -SamAccountName -GroupCategory $grpcat -GroupScope $grpscp -Description "Members of this group are Administrators"

Add a comment
Answer #2

The code listed here as the answer doesn't work and gets flagged for plagiarism when submitted, leading to a score of 0 and reporting to the program. Please don't use it!

source: Instructor
answered by: shauntu
Add a comment
Know the answer?
Add Answer to:
Create 3 PowerShell Scripts. The first 2 are worth 2 points each. The 3rd one is extra credit, wo...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT