You are on page 1of 2

7/22/22, 2:20 PM Case Study - Part 1 [Due Saturday, July 23, 2022 at 11:59 PM Eastern] (page 4 of 6)

Question 3

Not yet answered

Marked out of 15.00

Problem
Jen manages all the file servers, and she says that the research division of the company just hired 30 new people
that will all be starting tomorrow.

 
She needs to create a new shared folder for each of these new people. She explains that she got HR to export a list
of the people to a file, but she needs your help to use PowerShell to use that file to create the shared folders.

 
You ask about NTFS permissions, and Jen says just to leave them as default because she already has a script that
will set the NTFS permissions and she will run it after running your script.
 

Please create a script that will:


 

1. Ask the user to type the path to a file; this is the file with the names in it (the same .csv file from the last
question). Store the value in a new variable.

You must verify that the user typed the path to a file that exists. The user can only proceed if what they
typed meets this criteria.

Example: C:\Users\User\Desktop\NewHires.csv

 
2. Ask the user to type the path to a folder; the new shared folders should be created inside this folder. Store
the value in a new variable.

You must verify that the user typed the path to a folder that already exists. The user can only proceed if
what they typed meets this criteria.

Example: C:\Shares\

 
3. Create a new function called New-EmployeeShare that accepts two parameters and will return one
PSCustomObject.
The two parameters be as follows:
The full path to the file with the employee names inside it.
Full path to the folder in which the shared folders will be created.

The one object that is returned must contain the following properties:
First name.
Last name.
Full path to the new shared folder.
UNC path to the new shared folder.

 
The output must be created using a PSCustomObject. See https://docs.microsoft.com/en-
us/powershell/scripting/learn/deep-dives/everything-about-pscustomobject?view=powershell-7.2 for
more info.
The following logic will be placed inside your new function:

 
3.1 For each of the new employees listed in the file, create a new folder

You must verify if the folder already exists or not. If it already exists, do not try to create it.
If you skip a folder because it already exists, you must still complete the next step: 3.2 below.
https://moodle.cambriancollege.ca/mod/quiz/attempt.php?attempt=2189704&cmid=1897028&page=3 2/3
7/22/22, 2:20 PM Case Study - Part 1 [Due Saturday, July 23, 2022 at 11:59 PM Eastern] (page 4 of 6)
The folder name should use the following structure:
All lower case.
The first two letters of the user's first name followed by their entire last name.

 
Example Full Path for a user named Nathan Abourbih: C:\Shares\naabourbih\

 
3.2 Instruct Windows to share this folder and give the share the same name as the new folder. The
share permissions should be Everyone - Full Control.

You must verify if the folder is already shared or not. If it is already shared, do not try to share it
again.

Example UNC Path for a user named Nathan Abourbih: \\ComputerName\naabourbih

 
 

4. Execute your new function by passing the two parameters into it and save the result to a new variable.

 
5. Display the contents of the new variable using the Format-Table cmdlet (in this order):

First name.
Last name.
Full path to the new shared folder.
UNC path to the new shared folder.

Marking
Please review the rubric in Moodle to see how this question is marked.

 
Please type the word "done" into the answer box below. Your answer to this question should be included in the
single script file that you will create and submit using the file submission portion of this moodle module.

Answer:

Previous activity
◄ Thurs June 23 - Zoom recording, passcode j$U+64$x

Jump to...

Next activity
Case Study 1 - Rubric ►

 Data retention summary

 Get the mobile app

https://moodle.cambriancollege.ca/mod/quiz/attempt.php?attempt=2189704&cmid=1897028&page=3 3/3

You might also like