Learning PowerShell – Homework Ten Answers


PowerShell Homework Ten

By: Steven Aiello

Answer the questions as best as possible in your own words. By answering the question in your own words you will learn more than simply repeating what you’ve heard. You are encouraged to visit the source links in the lessons to do more research on the subject.

Remember the point of the homework is not simply to finish, but to learn!

1. What PowerShell command did you use to display all the processes running on your system?

The PowerShell command to display all the processes currently running on the system is: Get-Process

2. What two commands did you use to write your menu to the window, and what command did you use to receive the input from the user?

The two commands to write the menu and read the input from the user are: Write-Host and Read-Host

3. What looping method did you use to keep the user in the script and why?

I personally used the “While” loop to run because I had set my “$RUN_AGAIN” variable equal to “yes”. I then continued to test for that condition until the user set that value to anything else expect but yes which would terminate the script. You could have also used a “for” loop just as well. The only loop that may not work very well for this type of menu would be a “for each” loop which iterates through an array.

4. What logic statement did you use to evaluate the user input for the script menu?

As mentioned in the homework I used and recommend using “Switch” statements for simple menus. It makes handling the input from the user very easy. If there’s a specific amount of menu options you can build your Switch statement to match those cases.

5. How could you expand this script to make it more useful?

If you wanted to get very advanced and were deploying similar services in an environment you could build a menu driven script to install and remove server rolls like file and print, SMTP, or Active Directory services. There are really many ways you could expand this script, however, this is just one example.


Leave a reply

five + = six

This site uses Akismet to reduce spam. Learn how your comment data is processed.