Create cool dialog or message box with PowerShell and WPF


In this post, I will an easy way to display cool messagebox or dialogs with PowerShell and WPF.

How to get samples ?


What is it ?
The library I will talk about it is called SimpleDialog.
It has been created by Maurício Vielmo Schmaedeck who did a really nice job.
You can find the GitHub repo here.

How it looks like ?
The library is composed of 6 dialogs.
- Information
- Success 
- Warning
- Error
- Critical error
- Progress

Where to find it ?
You can find the library on this GitHub repo.

How to install it ?
1 / Create a folder assembly
2 / Create a folder resources
In this step I guess you already have a ps1 and XAML files. If not you can find them in the download link.
My project will look like as below:
3 / Download the Nuget.exe file. You can find it here.
4 / Copy the nuget.exe in your project folder.
5 / Now we will download the required dll to play with the library
6 / Use the below command to download it.
7 / The DLL file will be available in the folder SimpleDialogs.1.0.3\lib\net45
Note that the version may change.
8 / Copy the SimpleDialogs.dll file to the assembly folder previously created
Now we have everything we need, let us see how to implement it.

How to implement it ?

XAML part
1 / Copy the below lines in the Window part.
2 / See below my Window part after
3 / Add the below Resources part after the Window part.
4 / See below my full XAML file.

PS1 part
1 / Add the below line, at the beginning of your script, to load the assembly
2 / Your dialog will be displayed after clicking on a button.
We will now see how to use it.

How to use it ?
The simpleDialog is composed of 6 dialogs which are divised in two classes AlertDialog and ProgressDialog.

The dialogs below will be used in the class [SimpleDialogs.Controls.AlertDialog]
- Information
- Success 
- Warning
- Error
- Critical error

The Progress dialog will be used using the class [SimpleDialogs.Controls.ProgressDialog]
Use the below part to create and display your Alert Dialog
Use the below part to create and display your Progress Dialog
To choose what kind of dialog to display you have to play with the AlertLevel property.
See below which AlertLevel to use depending of the Dialog
- Information: information
- Success: Success 
- Warning: warning
- Error: error
- Critical error: critical

See below how to use it:
To change title and message of your Dialog use the below properties:
See below how to use it:
By default Dialogs will look like as below:


Customize the Dialog
There are several properties available to customize the main design of the design like colors, buttons...
To customize it, use the below properties (I don't use all of them in this sample)
For instance if you want to change the main color of a Dialog use the property Foreground.
You can also choose what kind of button to display in your Dialog. For instance you can choose to dislay a Yes and No button or also choose to display a Copy to clipbard button. This one will copy text content in the clipboard.
In the below GUI, I added some properties to customize to change the design of my Dialogs.

See below all properties available for the AlertDialog
See below all properties available for the ProgressDialog

Create your own MDT FinishAction


In this post, I will show a quick tip that allows you to create your own finish action, in order to execute a specific action after clicking on the Finish button or at the end of the deployment.

Context
In MDT a variable called FinishAction allows you to do a specific action when deployment is finished. 
This action is done once you click on the Finish button or when the deployment is finished.
By default there are three actions available:
- Reboot or restart
- Logoff
- Shutdown
So why not creating a new one ?

What do I want ? 
Once the deployment is completed, I want to run the below actions:
- Create a folder C:\OSD_Logs
- Copy deployment logs in C:\OSD_Logs
- Copy DISM, panther ligs in C:\OSD_Logs\System
- Create system and applications evtx and copy them in OSD_Logs
- Reboot the computer
See below the PowerShell script I will use to do that. I named it SD_Reboot_Actions.ps1 and copied it in Scripts folder.

What to modify ?
1 / Open the file Litetouch.wsf
2 / Search the part Sub Reboot, by default as below:
3 / Copy it and rename it as, Sub Reboot_Custom, as below:
4 / Then call the PowerShell script in the Reboot_Custom as below:
5 / Now we have to choose a value for our custom FinishAction. This way we can call it from the customsettings.ini file or TS.
6 / In Litetouch.wsf search "Select Case UCase(sFinishAction)", by default as below:
7 / Choose a value to use, in my case MY_REBOOT and call your custom reboot action, as below:
8 / Now to use this new FinishAction, you will need to use it with the new created value for instance in the customsettings.ini, FinishAction=MY_REBOOT or in a Task Sequence step.

Create a cool WPF Menu with PowerShell and RadialMenu


In this post I will show you a really cool library that allows you to build a nice menu for your GUI like in the preview picture.

How to get sample ?

What is it ?
The library I will talk about is called RadialMenu.
It has been created by Julien Marcou who did a really nice job on it.

Where to find it ?
You can find this library on this Gitub repo. Everything is very well explained.
You can find also the Nuget package on the Nuget websit, here.

How to install it ?
1 / To install it, download the Github repo folder in order to get the assembly file.
Now you have downloaded the repository, we will create our project.
2 / Create a folder assembly
3 / Create a folder resources
My project will look like as below:

4 / In the downloaded folder go to the resources folder
5 / Copy the RadialMenu.dll file to the resources folder previously created

6 / Go in the RadialMenuDemo > Utils folder
7 / Copy the Icons.xml file to the resources folder previously created

Now we have everything we need, let us see how to use it.

How to use it ?

XAML part
Copy the below lines in the Window part.

Copy the below Resources part below the Window part.

Now to create your menu follow the below structure.

As you may noticed the menu is divised in two parts
- The centralitem menu this one that allows you to close the menu
- The other menu

As mentioned above, you can choose easily your icon to display in the menu.
In order to have an overview of what looks like each icon, you can go to this site.
If you type for instance user in the search bar, it will display the below icons. Choose yours and replace the character "." by a "_".
In the above example to use the icon "appbar.user" we will change it "appbar_user".

PS1 part
Add the below line to load the RadialMenu assembly.

The only thing you will need to use it is to open or hide the menu.
It will work like the Flyout part from Mahapps.
Indeed to open or close the menu proceed as below:

The menu action should be done from a button. 
In the below example I created a simple menu which is displayed after loading the GUI. 
Once you click on the close button, it will hide the menu and display a button that allows you to display again the menu.

You can also call a second menu from an item.
For that just create a second menu structure by changing its name.
See below an example of a second menu.


How to change the design ?
It's possible to custmize the menu design.
For that copy the below part just below the line <RadialMenu:RadialMenu Name="MainMenu" IsOpen="true">.

See below the new design in action.
Of course you can customize it as you want.

Menu in action
See below an idea about how to use this menu in your GUI.
In this example I use Mahapps and the RadialMenu.
A button to interact (open/close) the menu is localised in the titlebar.
You can find this example in the With_datagrid folder from the link above in my post or here.






Use PowerShell to be notified for new blog post


In this post I will show a little script that allows you to be notified when new content is available on a blog, site... from a list of site. It will allow you to set a list of blog (in an XML file) to check and be aware when something new has been published on one of them.

Quick AD Support (QADS) - New version


In this post I will show you the new version of the Quick AD Support tool (QADS). 
In this new version you will be able to execute action (enable, disable, unlock, remove, change password) on an AD Object (user or computer) from your normal account. 
Indeed a new menu will allow you to set your admin account in order to run actions with admin credentials.

Create your own MDT Final Summary wizard with PowerShell


In this post I will show you how to replace the existing final summary wizard with a GUI created with PowerShell and Mahapps. This wizard will also a log folder that will contain deployment logs and event logs in order to have the computer state at the end of the deployment. 

PowerShell tool - Quick AD Support (QADS)


In this post, I will show you a tool I created, that allows you to display informations about a user or computer from Active Directory quickly from the systray. It will also allows you to do some actions like unlock user account, change password and view group membership for a user.