Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

need help with powershell script challenges

$
0
0

Hello everyone,

I am just needing assistance on how to write these challenge scripts, any help is greatly appreciated, this would definitely help me understand so I can study for a test coming up.

 

challenge 11 - 

Create a script that will export user information from Active Directory to a csv file.

The script will prompt the user for the Organizational Unit name from which to export user information .

If the Organization Unit is not valid, display an error message and exit the script

The script will prompt for the path to the output file.  If the file already exists, ask if it can be overwritten.  If the file should not be overwritten, exit the script

The script will generate the following output using the export-csv cmdlet.

You will have to determine which two properties will provide the necessary information. 

You will want to use the Select-Object cmdlet with  advanced formatting using hash tables.

 

Output file will look similar to the following.

 

"Employee Name","Email Address"

"Tony J. Green","tony.green@acme.com"

"Chad K. Baker","chad.baker@acme.com"

"Jason L. Walker","jason.walker@acme.com"

"Alan M. King","alan.king@acme.com"

"Sarah N. Carter","sarah.carter@acme.com"

"Todd O. Roberts","todd.roberts@acme.com"

"Theresa P. Rodriguez","theresa.rodriguez@acme.com"

"Antonio Q. Hernandez","antonio.hernandez@acme.com"

"Larry R. Perez","larry.perez@acme.com"

"Virginia S. Lopez","virginia.lopez@acme.com"

"Tim T. Mitchell","tim.mitchell@acme.com"

 

"Maria U. Garcia","maria.garcia@acme.com"

 

-----------------

 

challenge 12 -

 

Active Directory

Create a script that search for user accounts in each organization unit in the domain.  For each Organizational Unit that contains user accounts  display the Organization Unit name heading followed by a list of user accounts.

Note:  A user account objects’ ObjectClass property will be equal to “user”.   You may want to use this property to select only user accounts from the OU.

Your output should look similar to the following:

Customer Support Users

----------------------

Harold H. Reed

Mary G. Adams

Walter I. Turner

 

Finance Users

-------------

Ashley F. Martin

Joan D. Williams

Scott E. White

 

Sales Users

-----------

Anna C. Taylor

John A. Smith

Steven B. Johnson

 

Information Technology Users

----------------------------

Chad K. Baker

Jason L. Walker

 

Tony J. Green

 

-------------------

 

challenge 13 -

 

Active Directory

Part 1

Create a script that search for computer accounts in the domain and output the computer name to a text file.   The script will prompt for the output file.  Test if a file of the same name already exists, if it does, prompt if it should be overwritten.  The output file should look similar to the following:

ACMESERVER

smithj-pc

johnsons-pc

taylora-pc

williamsj-pc

whites-pc

.

.

.

martina-pc

adamsm-pc

reedh-pc

turnerw-pc

greent-pc

bakerc-pc

windows7-pc

WIN2012

 

Part 2

Create a script that will use this text file to test the connection to each of the computers in the domain.   If the computer is not responding, display the message “ComputerName - not available” .  If the computer is responding display the message “ComputerName– available”

ComputerNamewill be the name of the computer currently being tested.

Output will look similar to the following:

ACMESERVER - available

petersonp-pc - not available

baileyc-pc - not available

windows7-pc - available

 

WIN2012 - not available


Viewing all articles
Browse latest Browse all 6937

Trending Articles