Closed hotzenwalder closed 2 years ago
You should use the following function for detection rules:
New-IntuneWin32AppDetectionRuleRegistry
Since it will create the required odata.type object: #microsoft.graph.win32LobAppRegistryDetection
Requirement rules are different, and the function you're using created a '#microsoft.graph.win32LobAppRegistryRequirement' odata.type object.
I'm trying to add an win32app with a requirement for a registry string comparison, but no matter what I try it always gives me the below error
WARNING: Request to https://graph.microsoft.com/Beta/deviceAppManagement/mobileApps failed with HTTP Status BadRequest and description: Bad Request WARNING: Failed to create Win32 app using constructed body. Passing converted body as JSON to output.
When I use another detection method, like a Powershell script it works. The error is somewhere in my $detectionrule. I've checked the module New-IntuneWin32AppDetectionRuleRegistry to see what the command should look like, but if always fails, even when I use another type like Existence
My detectionrule is
$DetectionRule = New-IntuneWin32AppRequirementRuleRegistry -StringComparison -StringComparisonOperator equal -KeyPath $RegKeypath -ValueName $RegKeyValue -StringComparisonValue $Version
This transalates to
My code to add the win32app
Add-IntuneWin32App -FilePath $IntuneWinFile -DisplayName $DisplayName -Description $Description -Publisher $Publisher -InstallExperience $InstallExperience -RestartBehavior $RestartBehavior -DetectionRule $DetectionRule -InstallCommandLine $InstallCommandLine -UninstallCommandLine $UninstallCommandLine -Icon $Icon -Verbose
With the below detectionrule it works, so all the other parameters in the command are fine.
It just bombs out whenever I switch to a New-IntuneWin32AppRequirementRuleRegistry.
Tried almost everything, so no idea what I am doing wrong here