PowerShell and WPF: Use DatePicker Control to create a quick booking system

In this post I will show you how to use the DatePicker WPF control with PowerShell. 
We will see how to select dates and  how to display available and unavailable dates in a calendar.
I will then show you a booking tool example that will allow a user to type his name, select a date and save infos in a CSV.

PowerShell and WPF: Customize MahApps Dialog


By default MahApps Dialogs are displayed with default text like OK and Cancel. In this post, I will show you how to change those values and add your own text.

The default behavior
In this below example a simple validation dialog with OK and Cancel button is displayed.
To display this dialog I used the class MessageDialogStyle with method AffirmativeAndNegavtive to display an OK/Cancel dialog.
See below the result (as you can see, buttons are OK and Cancel by default):

Now let's see how to change button values.

MetroDialogSettings: Customize your dialog
To replace OK and Cancel values, you have to use the class MetroDialogSettings:
[MahApps.Metro.Controls.Dialogs.MetroDialogSettings]

We will first create the object for this class, as below:
See below available properties for this object:
As you may noticed there are two properties that will be helpful to customize our buttons text:
- AffirmativeButtonText : OK
- NegativeButtonText : Cancel

Now we will change those properties and add our text and apply them to our object Button_Style:
See below the full code:
See below the result:


More custo
Change Dialog theme
You can change the dialog theme using the ColorScheme property that contains three values:

See below the dialog in action depeding of those properties:
Dialog with Accented
Dialog with Inverted
Dialog with Theme

Change dialog title size
See below the default dialog Title size:
You can change it easily using the DialogTitleFontSize property, as below:
See below the new result:


Change dialog message size
See below the default dialog message size:
You can change it easily using the DialogMessageFontSize property, as below:
See below the result:

What's next ?
In the next post I will explain how to diplay differents kinds of dialog using MahApps API.
- Basic Dialog
- Validation Dialog
- Input Dialog
- Login Dialog

Pause a Task Sequence on the fly from a keyboard shortcut


In this post I will show you how to pause a Task Sequence when you want as many times you want by pressing a keyboard shortcut like F4.
I will also show you a short tool called TS Pause that allows you to pause the TS on the fly.

Context
You want to test something in your Task Sequence and you need to pause your Task Sequence.
You don't want to pause the TS at a specific step but to pause it when you want during the process.
You want to be able to pause your TS as many times you want.
You want for instance to be able to pause the Task Sequence using the F4 key from your keyboard.

Pause the TS dynamically
In my previous post I explained how to pause the TS on the fly.

See this post here.
We will now see how to do it from a keyboard shortcut.

Where to get files ?


Prerequisites
Add the required part of code to pause the TS in the ztiutility.vbs file, as menioned here
PowerShell integrated in your boot image
Add files from the downloaded folder in your boot image

How it works ?

Pause from keyboard shortcut
1. Run a deployment
2. Press F4 to pause the TS
3. A msgbox will be displayed (Note that there may be a little delay after before the msgbox)
4. Click on OK to continue the TS

See below an overview:


Pause from TS Pause tool
In this example we will open a quick GUI at the beginning of your deployment and click on the pause button to pause the TS when you want.
1. Run a deployment
2. Press F4 to display the TS Pause GUI
3. Click on the pause button to pause the TS
4. A msgbox will be displayed
5. Click on OK to continue the TS

See below an overview:


How to integrate it ?
1. Add files below from the downloaded content in your boot image
- run_keys.cmd
- TS_Pause.exe
- winpe_keys.exe
- winpeshl.ini
2. Update your Deployment Share  or boot image

Choose your shortcut
Some weeks ago I published a post that explained how to add your own keyboard shortcut in WinPE.
See this post here.
You will learn how to choose the apropriate shortcut.

Pause a Task Sequence when you want with just a variable


In this post I will show you how to pause a Task Sequence on the fly using just a TS variable. You will be able to pause a TS when you want without to add a step in your TS, as many times as you want.

Context
You want to test something in your Task Sequence and you need to pause your Task Sequence.
You don't want to pause the TS at a specific step but to pause it when you want during the process.
You want to be able to pause your TS as many times you want.
You want for instance to be able to pause the Task Sequence using the F4 key from your keyboard (we will that in the next post)

The existing way
There are many nice posts about how to pause a Task Sequence. 
See below some of them:
SCCM Pause a Task Sequence
Pause a TS with no package
Pause a TS (Windows noob)
Pausing a TS, a bit different

In all those posts, you have to create a specific step to pause the Task Sequence, meaning you will pause it only at this specific time. 
If you want to pause it again you have to restart the deployment, add a new pause step and start again the deployment.

The new way
With this method you won't have to create a step in your TS to pause it.
You will be able to pause the TS dynamically, as many times as you want.

How it works ?
1. In order to pause the TS on the fly I modify the file ztiutility.vbs
2. I created a TS variable TSPause.
3. If the variable TSPause equals TRUE a msgbox will be displayed.
4. The msgbox will automatically pause the Task Sequence.
5. Once you click on the OK button, the variable TSPause will be set again to FALSE and the TS will continue.

How to implement it ?
1. Open the file ztiutility
2. Search the function Public Function ReportProgress. I choose this one because it's use all the time during the deployment.
3. Add the below code just below the part Dim uMaxStep
4. Update your Deployment Share

Dynamic pause in action
In the below example I proceed as below:
1. Create the TS object: 
2. Set the TSPause variable to TRUE
3. A msgbox will be displayed and pause the TS

See below the pause in action:

In the below example I added a button pause in my Task Sequence Debugger for MDT, available here.
This version will be soon available. 

In the below example I paused a TS just using a keyboard touch.

The uservoice
Three years ago I created a post about how to add the complete progression in the progress bar, as below:

I also opened a UserVoice which has bee accepted and implemented in SCCM recently, see here.
That's why I open a new uservoice, in order to add a new variable TS pause with ztiutility action to pause the TS dynamically.
Click here to vote for this idea and implement it in SCCM.

What's next ?
- Pause the TS dynamically with a keyboard shortcut
- Pause the TS from the Task Sequence Debugger