Converting C# code to Powershell syntax by sample

For the last few months I’ve been learning how-to create Powershell scripts to help manage our servers and build
solutions for our users. First, I will show a sample C# code that will display a more complex messagebox in action.
You can build a windows form with a button control and then add the C# code to test that this code works.

Here’s the C# code:

Here’s the converted C# code to Powershell syntax:

Make sure to add this Powershell code to a *.ps1 file to run it. Or, just copy/paste code to the shell to run interactive.
Now, you might asked the question, Can I build and convert a simple Windows form(s) solution to a Powershell syntax?
The answer is YES.  Happy Powershell coding!


About maxt2posh

I’m from Puerto Rico, have been working with computers since 1979. Throughout many years, I have worked with SQL Server Technologies, provided support to Windows Servers/Client machines, Microsoft Virtualization Technologies, and build some Visual Studio solutions. I’m a Microsoft PowerShell MVP since 2009 and MVP SAPIEN Technologies since 2010. I speak in most of the SQLSaturday, IT Pro and .NET camps events around the Florida’s State. Also founder of the Florida PowerShell User Group which meeting every 3rd Tuesday evening of the month.
This entry was posted in PowerShell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s