MSEndpointMgr / IntuneWin32App

Provides a set of functions to manage all aspects of Win32 apps in Microsoft Intune.
MIT License
345 stars 88 forks source link

Issue with defining multiple requirements via New-IntuneWin32AppRequirementRule #43

Closed g3rhard closed 1 year ago

g3rhard commented 2 years ago

Hello! Based on notes from https://github.com/MSEndpointMgr/Events/blob/master/SCUGSE-2020-10/5-Additional.ps1 I tried to create "array" with a few requirement rules:

### Define array
$RequirementRules = New-Object -TypeName "System.Collections.ArrayList"
### Define rule 1
$RequirementRule1 = New-IntuneWin32AppRequirementRule -Architecture All -MinimumSupportedOperatingSystem 1607 `
  -MinimumFreeDiskSpaceInMB $MinimumFreeDiskSpaceInMB
$RequirementRules.Add($RequirementRule1) | Out-Null
### Define rule 2
$RequirementRule2 = New-IntuneWin32AppRequirementRuleRegistry -VersionComparison `
  -KeyPath "$KeyPath\$ProductCode" -ValueName "DisplayVersion" -VersionComparisonOperator "lessThan" -VersionComparisonValue $AppVersion
$RequirementRules.Add($RequirementRule2) | Out-Null

but I got this error:

Add-IntuneWin32App : Cannot process argument transformation on parameter 'RequirementRule'. Cannot convert
the "System.Collections.ArrayList" value of type "System.Collections.ArrayList" to type
"System.Collections.Specialized.OrderedDictionary".

....

+                   -RequirementRule $RequirementRules -InstallCommandL ...
+                                    ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-IntuneWin32App], ParameterBindingArgumentTransformation
   Exception
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-IntuneWin32App

Library version: 1.3.3

Maybe there is another way how to handle few requirement rules?

NickolajA commented 2 years ago

$RequirementRules = New-Object -TypeName "System.Collections.Specialized.OrderedDictionary"

This should do the trick.

g3rhard commented 1 year ago

Thanks, I'll close issue at this point.