Intune Proactive Remediation: Powershell-Skript not finding Registry-Path

Simon Aebi 21 Reputation points

First: I'm not that good at powershell, but some easy scripts are ok. Right now i'm facing a problem and i just can't find the solution.

Within Intune i try to implement a detection script that detects a value within the registry if its 1. Here's the script i did:

$value = Get-ItemPropertyValue -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost' -Name "4G"

if ($value -eq 1)
write-host "Compliant:True"
exit 0
write-host "Compliant:False - run remediation"
exit 1

write-host "Comliant:False - run remediation"
exit 1

If i start this script manually with powershell (admin), the script works just fine. But if i deploy the script trough intune proactive remediation, it always tells me that theres no specific registry path - but its there fore sure. I first thought i may be the conext in whicht powershell via intune runs - but what else than system or admin should it be...

I see it comming - the solution will be absolutly clear and easy once someone will give the answer :D

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,180 questions
Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
3,692 questions
0 comments No comments
{count} votes

Accepted answer
  1. Crystal-MSFT 36,666 Reputation points Microsoft Vendor

    @Simon Aebi Based on my research, if we run script in a 64-bit Powershell host on a 64-bit client architecture, we can set "Run script in 64-bit PowerShell host" as Yes:

    Meanwhile, find an article mentioned to write registry keys in x64 hive and not WOW6432Node. We can read it for the reference.
    Note: Non-Microsoft link, just for the reference.

    Hope it can help.

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

2 additional answers

Sort by: Most helpful
  1. MotoX80 29,371 Reputation points

    Intune is probably running in 32 bit. mode.

    1 person found this answer helpful.
    0 comments No comments

  2. Simon Aebi 21 Reputation points

    Thanks guys

    That was the case - 64/32bit! Thanks a lot and stay safe :)