Loading...

Display toast notification with Header picture to user in System context through Intune Proactive Remediation


In this post I will show you how to display toast notification with header picture for user in SYSTEM through a Proactve Remediation script or MECM.


Context

- You want to install an application on a devices

- You want to check something or do n action

- This requires to be executed with SYSTEM account

- You want to display a toast notification on device after install

- You want that this notification is displayed on the user session

- You want to add a picture as header in your notification


The issue

There is two cases.

Case 1: System context

The script is executed in system context.

The application is installed but notification is not displayed for user.

This is because we are running in system context.

Indeed, if you run this kind of toast in system context or even in admin, you will get an Access Denied error.


Case 2: User context

The script is executed in user context.

The application will need admin rights to be installed.

The notification is displayed in for user.

This is because we are running in user  context.


The solution

In order to display a toast notification with header in system context but for user we will use an awesome PowerShell module.

This one is called RunAsUser and has been created by Kelvin Tegelaar.

You can find the GitHub repo here.

In my case I included all in one script in order to use it in a Proactive Remediation script.


Get the script

You can download the script example by clicking on the below picture.

There are two files:

- Toast_Remediation_SYSTEM_InstallModule.ps1

- Toast_Remediation_SYSTEM_NoModuleInstall.ps1


The first one will install module RunAsUser and removes it at the end.

The second one will not install module but export required files.


The toast notification

The toast notification I will display looks like as below:



Change text

You can easily customize text in the toast notification.

For that proceed as below:

Search fo the "Toast text part" line, see below:

You can customize there text as below:


Change toast picture

You can easily add your own picture in the toast.

The first step is to convert your picture to base64.

For that proceed as below:

Then copy, the code in the variable $Picture_Base64.


Implement in Intune

For that we will use the Proactive Remediation part.

The toast notification script has to be executed as remediation script.

1. Go to the Microsoft Endpoint Manager admin center

2. Go to Reports

3. Go to Endpoint Analytics

4. Go to Proactive Remediations

5. Click on Create script package

6. Type a name

7. Click on Next

8. Click on Detection script file

9. Choose your detection script

10. Click on Remediation script file

11. Browse the script Toast_Remediation.ps1

12. Click on Next

13. Select the group

14. In the Schedule part, choose when the package should be run.

15. Click on Apply

16. Click on Next

17. Click on Create


Implement in SCCM

For the MECM part just create a new application and execute it with SYSTEM account.

toast system 2581642260735481297

Enregistrer un commentaire

2 commentaires

TxalsTauri a dit…

Hello,

this script is really awsomw. I'm using it and wotks perfectly but there is an issue that I'm not able to find out. The toast is shown but the image not, but if I check on the folder is created and it's there, but is not shown on the the toast ... the image have shown randomly in a few ... but on the most of them is not shown

Have you seen it before ?

Thanks a lot

TxalsTauri a dit…
Ce commentaire a été supprimé par l'auteur.
Accueil item

Award

Sponsors

You want to support me ?

Mes articles en français

Endpoint Manager award

Author of Books

Stats