Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 568435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:11:19+00:00 2026-05-13T13:11:19+00:00

I am trying to show a message box from PowerShell with yes and no

  • 0

I am trying to show a message box from PowerShell with yes and no buttons.

I can display a message box with an OK button:

[system.windows.forms.messagebox]::show("Hello, world!")

And I can create a variable $buttons with the buttons I want:

$buttons=[system.windows.forms.messageboxbuttons].yesno

And I can see that the Show() static method is overloaded and that one of the options is to give three parameters:

Show(String, String, MessageBoxButtons) Displays a message box with specified text, caption, and buttons.

So naturally(?) I decided to call this:

[system.windows.forms.messagebox]::show("Are you sure?","",$buttons)

And this results in an error:

Cannot find an overload for “Show” and the argument count: “3”.

But there IS an overload for “Show” that accepts three arguments!

What am I doing wrong?

(And can someone tell me why calling a method in PowerShell is usually done by using the dot syntax: object.method() but requires “::” for the MessageBox class? It’s confusing.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:11:19+00:00Added an answer on May 13, 2026 at 1:11 pm

    Correct way of doing this can be

    $buttons=[system.windows.forms.messageboxbuttons]::yesno;
    [system.windows.forms.messagebox]::Show("Are you sure?","",$buttons);
    

    Notice “::” instead of “.” in the first line. YesNo value is defined staticly on System.Windows.Forms.Messageboxbuttons, so you must use “::” (static call) instead of “.”

    Note that “[system.windows.forms.messageboxbuttons].yesno” is an attempt to call a “YesNo” property on an instance of System.Type, which does not exist and therefore result in a $null

    Hope it helps !

    Cédric

    Edit —

    Keith solution using an implicit cast made by powershell for the enum is more elegant.
    It just does not work on PS V2 CTP 3 which I still use but work fine on RTM version.
    The complete explication was worth giving, though…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get the message box to show the elements but messagebox
I am trying to change a certain text box message. It will display my
I'm trying to get ghostscript to render a pdf file from a Windows box.
I am trying to display 3 values in a message box when the user
I have below query I am trying to show message 'No SubSource for this
please i am trying to make the message show on newline as the customer
See this question. How to show popup message like in stackoverflow I am trying
Im trying to make a JDialog that will show the user a dynamic message
I'm trying to show a UIAlertView before actually deleting a cell from a UITableView
I have a form that is showing a MessageBox using MessageBox.Show, and trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.