Intune Powershell Scripts – Encoding Gotcha

Written by James McDonald

June 25, 2021

Just had a powershell script that was failing

When I went in to the registry key that stores the results of the script running I saw some corrupted characters

The problem turned out to be I had a file that was encoded in UTF-16LE

So I saved the powershell script as UTF-8 and then deleted the current script and re-uploaded and it worked fine

Write-Host “Running Remove Mail App”
Get-AppxPackage Microsoft.windowscommunicationsapps | Remove-AppxPackage
Write-Host “End Remove Mail App”

And another thing

How to map your Powershell Script registry Output to the corresponding Item in Intune

Open the Powershell script in Intune and check the url note how the registry key GUID corresponds to the URL



Submit a Comment

Your email address will not be published.

You May Also Like…

PHP Iterators

Just came across a Youtube talk "Iterators in PHP" by Jake Smith published in 2014 that steps through the many...

PHP array_map Multiple Arrays

array_map can take multiple arrays. I like how it starts mapping through them starting at the first element of each...