Display System.Management.Automation.Host.ChoiceDescription as a list?

Posted on 2009-04-22
Last Modified: 2012-06-21
If I have the code as shown below, I get the output as shown in the attached picture. How do I get the options to display in a list mode that looks like the following?

[A] Option A
[B] Option B
[C] Option C
# Clears the Screen


# Define Main Level Title and Message Variables

$main_title = "PowerShell Network Management Console v1.0"

$main_message = "What management tasks would you like to perform?"

# Define Main Level Menu Options

$main_activedirectory = New-Object System.Management.Automation.Host.ChoiceDescription "&Active Directory Related", "Performs tasks related to Active Directory management."

$main_computer = New-Object System.Management.Automation.Host.ChoiceDescription "&Computer Related", "Performs tasks on and retrieves information from the specified computer or computers."

$main_exchange = New-Object System.Management.Automation.Host.ChoiceDescription "&Exchange Related", "Performs tasks related to Exchange management."

$main_quit = New-Object System.Management.Automation.Host.ChoiceDescription "&Quit", "Quits the PowerShell Network Management Console."

# Display Main Level Menu Options

$main_options = [System.Management.Automation.Host.ChoiceDescription[]] ($main_activedirectory, $main_computer, $main_exchange, $main_quit)

# Prompt for Main Level Menu Choice

$main_result = $Host.UI.PromptForChoice($main_title, $main_message, $main_options, 3)

# Handle Main Level Menu Choices

switch ($main_result)


		0 {ActiveDirectory_Menu}

		1 {Computer_Menu}

		2 {Exchange_Menu}

		3 {Quit_Menu}


Open in new window

Question by:dfxdeimos
    1 Comment
    LVL 15

    Accepted Solution

    Figured it out, I had to do something like what you see in the code example.
    # Prompt for Main Level Menu Choice
    $Main_Prompt = '
    [1] Active Directory Menu
    [2] Computer Menu
    [3] Exchange Menu
    [4] Quit
    # Handle Main Level Menu Choices
    switch (Read-Host $Main_Prompt)
    		1 {ActiveDirectory_Menu}
    		2 {Computer_Menu}
    		3 {Exchange_Menu}
    		4 {Quit_Menu}

    Open in new window


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    A commonly asked question on the site recently has been regarding how do I share the GAL between different forests? I want a list of Contacts representing all the users in a remote domain, How do i get them? It's a problem I was posed with a litt…
    Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now