Question: ---Objective--- Write a PowerShell script to Create the following output: Enter Users Full Name : Enter Users ID : Enter Users Job Location : Enter

---Objective--- Write a PowerShell script to Create the following output: "Enter Users Full Name :" "Enter Users ID :" "Enter Users Job Location :" "Enter Users Manager Code :"

---Requirements--- Script output must be piped into a file named info.usr. Script must have while-loops to prompt the user for extra entries. Script must print out already-printed information should an error and cls occur. Script must have if-elseif and while, statements to ensure that any input does not bypass the rules above. (Example: if the char length of userID = 6, and only has numbers, then the variable 'code' is iterated to show that it is safe to move on to the next step. Otherwise, print an error and retry.)

---Self-notes--- I have an idea of how it would go.... -----------------------------------------------------

$userFN $userID $JobLoc $MngrID $done=0 $code=1

while ($done==0) { while (code==0) { echo "Do you want to do another one? (1=Yes/0=No):" read-host choice if (/* choice ==1*/) //If choice is yes (1) { code=1 //set code to 1 to initialize fullname sequence } elseif(/*choice==0*/) //if choice is no (0) { code = 5 //set code to 5 to stop any sequences from activating. done = 1 //set done to 1 so the application can terminate. } }

while (code==1) { "Enter Users Full Name :" read-host userFN if(/* userFN isAlpha*/) //if userFN only contains spaces and letters { code=2 //set code to 2 to initialize User ID sequence. } else { echo "ERROR: Entry must only contain letters and numbers. Please try again." read-host } //otherwise, print error and wait for the enter key to be pressed. }

while (code==2) { "Enter Users ID :" read-host UserID if(/* userID isDigit && input.length()==6*/) { code=3 //set code to 3 to initialize job location sequence. } else { echo "ERROR: Entry can only be a 6-digit number. Please try again." read-host } //otherwise, print error and wait for the enter key to be pressed. }

while (code==3) { "Enter Users Job Location :" read-host jobLoc if(/* jobLoc first 2 chars isAlpha && last 2 chars are digits*/ && input.length==4) //if input is 4 alphanumerical characters long... { code=4 //set code to 4 to initialize manager code sequence. } else { echo "ERROR: Entry must only contain letters and numbers. Please try again" read-host } //otherwise, print error and wait for the enter key to be pressed. }

while (code==4) { "Enter Users Manager Code :" read-host mngrID if(/* mngrID isDigit*/ && input.length() == 6) //If mngrID is 6 numerical characters long... { code=0 //set code to 0 to initialize retry sequence. } else { echo "ERROR: Entry must only contain letters and numbers. Please try again" read-host } //otherwise, print error and wait for the enter key to be pressed.

} //save to firstname_lastname.usr.... I've got nothing on this part....

}

--------------------------------------------------------------------------- It's funny how I only know how to do this in C, C++ and Java, as well as Unix scripting commands, but Powershell's rather complex in comparison. If anyone can help me with this

If anyone can help me with this, that'd be splendid

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!