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