Creating a Menu

by Apr 19, 2012

Hello,

I am in school and am looking for some help.  This is my assignment:

Unit 2 Lab Assignment 2

For this assignment, you will create a script that meets the following requirements:

  • Includes appropriate comments (see Role of Comments which is also located in the Course Materials and Resources in your Moodle course).
  • Clears the screen
  • Creates the menu displayed below with any additional formatting you may desire
  • "menu"

  • Prompts the user to choose a menu option
  • Assigns the value chosen by the user to the variable $choice
  • Prints "You chose option X" to the screen. Where X is the actual key that they pressed.
  • Requirements for "Show Services" menu item
    • Displays services sorted by status
    • Creates a csv file named services.csv with the same content and the data displayed on screen
  • Requirements for "Show Processes" menu item
    • Displays Process name and amount of Virtual Memory used
    • Display is sorted by amount of Virtual memory
    • The output is displayed in a web browser
    • Name the web page file processes.htm
  • Requirements for the "Show System Information" menu item
    • Displays output from systeminfo.ps1 script
  • Save the script as menu.ps1

This is the code I have so far:

$title = "System Utilities"
$message = "Select which utility you would like to view."

$A = New-Object System.Management.Automation.Host.ChoiceDescription "&A", ` "Show Services."

$B = New-Object System.Management.Automation.Host.ChoiceDescription "&B", ` "Show Processes."

$C = New-Object System.Management.Automation.Host.ChoiceDescription "&C", ' "Displays systeminfo.ps1"

$options = [New-Object System.Management.Automation.Host.ChoiceDescription[]] ($A, $B, $C)

$result = $host.ui.PromptForChoice($title, $message, $options, 0)

switch ($result)
    {
        0 {"You selected A." Get-Service}
        1 {"You selected B." Get-Process}
 2 {"You selected C." h:ist321systeminfo.ps1}
    }

I am getting an error message that says .menu is not a recognized cmdlet…..

I am not expecting y'all to do my homework but my teacher is not helping with this.  Any help would be greatly appreciated.