Intune Win32app requirement - Using a Powershell script

Jim Smith 21 Reputation points
2022-04-26T11:13:21.007+00:00

I am using a powershell script to check for a registry key (infact I'm checking all the values within a key, and excluding the values that we know should be there. if there is anything less the IF check outputs a 1.) Now running this script works fine, if there are additional values we get a 1 output. If I a remove any additional values, leaving only the value we expect to see then the script doesn't return anything.

Looking at all the docs (https://tech.nicolonsky.ch/intune-win32-app-requirements-deep-dive/ for example) it looks like I'm doing this correct.

But running the app on devices, they are all coming back as installed when I know for a fact all the devices have no additional values. I've ran the PS script manually on the device, and as expected the script returns no output.

I'm missing something very obvious here I'm sure!

$dir = Get-Item HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\AutoDiscover

$accounts = ($dir | Select-Object Property -ExpandProperty Property)

if ($accounts2 = $accounts -notmatch "myorgname.co.uk"){

Write-Host $accounts2

Write-output 1

Exit 0
}

196564-script.png

Microsoft Intune Application management
Microsoft Intune Application management
Microsoft Intune: A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.Application management: The process of creating, configuring, managing, and monitoring applications.
914 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Lu Dai-MSFT 28,366 Reputation points
    2022-04-27T07:25:34.663+00:00

    @Jim Smith Thanks for posting in our Q&A.

    For this issue, did you want to output the account when the account not match "myorgname.co.uk" in the registry? If yes, please understand that this commend "if ($accounts2 = $accounts -notmatch XXX)" only output "true" or "false", it will not output the account. If you want to output 1 and the account, please try to change the script like the following:

    $dir = Get-Item HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\AutoDiscover  
    $accounts = ($dir | Select-Object Property -ExpandProperty Property)  
    if ($accounts -notmatch "myorgname.co.uk"){  
    $accounts2 =$accounts  
    Write-Host $accounts2  
    Write-output 1  
    Exit 0  
    }  
    

    Hope it will help.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.