PrepAway - Latest Free Exam Questions & Answers

Which cmdlet should you add to the script?

Your network contains an Active Directory forest.
You set the Windows PowerShell execution policy to allow unsigned scripts on a domain
controller in the network.
You create a Windows PowerShell script named new-users.ps1 that contains the following
lines:
new-aduser user1
new-aduser user2
new-aduser user3
new-aduser user4
new-aduser user5
On the domain controller, you double-click the script and the script runs. You discover that
the script fails to create the user accounts.
You need to ensure that the script creates the user accounts. Which cmdlet should you add
to the script?

PrepAway - Latest Free Exam Questions & Answers

A.
Import-Module

B.
Register-ObjectEvent

C.
Set-ADDomain

D.
Set-ADUser

Explanation:
http://blog.coretech.dk/jgs/powershell-creating-new-users-from-csv-with-password-andenabled-accounts-orhow-to-pipe-into-multiple-cmdlets/
PowerShell: Creating new users from CSV with password and enabled accounts or How to
Pipe into multiple cmdlets
..
1. Import-Module ActiveDirectory
2. import-csv e:\users\newusers.csv |
3. New-ADUser -path “ou=test1,dc=contoso,dc=com” -passthru |
4. ForEach-Object {
5. $_ | Set-ADAccountPassword -Reset -NewPassword (ConvertTo-SecureString –
AsPlainText “Pa$$w0rd” –
Force)
6. $_ | Enable-ADAccount }


Leave a Reply