question

SimonAebi-6879 avatar image
1 Vote"
SimonAebi-6879 asked Crystal-MSFT edited

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

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"

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

}
catch{
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-powershellmem-intune-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Crystal-MSFT avatar image
1 Vote"
Crystal-MSFT answered Crystal-MSFT commented

@SimonAebi-6879 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:
https://docs.microsoft.com/en-us/mem/intune/apps/intune-management-extension#create-a-script-policy-and-assign-it

Meanwhile, find an article mentioned to write registry keys in x64 hive and not WOW6432Node. We can read it for the reference.
https://oliverkieselbach.com/2017/11/29/deep-dive-microsoft-intune-management-extension-powershell-scripts/
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.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@SimonAebi-6879 How's everything going? Did our issue resolve? If there's any update, feel free to let us know.

0 Votes 0 ·
MotoX80 avatar image
2 Votes"
MotoX80 answered

Intune is probably running in 32 bit. mode.

https://blog.italik.co.uk/running-powershell-scripts-using-intune/

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SimonAebi-6879 avatar image
0 Votes"
SimonAebi-6879 answered Crystal-MSFT edited

Thanks guys

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

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@SimonAebi-6879, Thanks for marking our reply as answer. I am glad that the issue is resolved. Congratulations! If there's anything else we can help in the future, feel free to post in our Q&A.

Thanks and have a nice day!

0 Votes 0 ·