Closed jbiskit closed 1 year ago
Update, things weren't actually working as I thought.
When I tried packaging up an application using the above mentioned requirement rule $requirementRule = New-IntuneWin32AppRequirementRule -Architecture All -MinimumSupportedWindowsRelease 20H2
it failed to package up the application indicating that the POST was a BAD REQUEST. Assuming the JSON was not formatted correctly.
I reviewed the JSON of a currently deployed application, and confirmed that instead of empty strings "", the values for minimumFreeDiskSpace, minimumMemoryInMB, minimumNumberOfProcessors and minimumCpuSpeedInMHZ were null.
In order for me to get an MSI file packaged and uploaded correctly, I needed to define full values within the requirementRule
The below worked $requirementRule = New-IntuneWin32AppRequirementRule -Architecture x64 -MinimumSupportedWindowsRelease 1909 -MinimumFreeDiskSpaceInMB 500 -MinimumMemoryInMB 1024 -MinimumNumberOfProcessors 1 -MinimumCPUSpeedInMHz 2400
I haven't found a way around this unfortunately, and its honestly a little cumbersome.
Yeah this feels like a bug, I'll look into it. Thanks for reporting it!
This seems to do the trick:
if ($PSBoundParameters["MinimumFreeDiskSpaceInMB"]) {
$RequirementRule.Add("minimumFreeDiskSpaceInMB", $MinimumFreeDiskSpaceInMB)
}
else {
$RequirementRule.Add("minimumFreeDiskSpaceInMB", "null")
}
Would you be able to test and modify your local function file and verify?
Also, I've updated the examples in the readme as you pointed out, they were unfortunately not kept up to date as the development of the module have progressed over time.
1.3.6 has now been released, which should include the fix for this issue.
I'll be honest and say that I made a mistake with 1.3.6, which has been corrected and is included in the soon to be released version 1.4.0 :)
I've just started to begin packaging up MSI files using the script and have ran in to some issues. Following the examples provided, it seems that a requirements rule is now mandatory since the latest updates to "New-IntuneWin32AppBody"
Below is an example
$SourceFolder = "C:\Temp\IntunePackagingScript\7zip" $SetupFile = "7z920-x64.msi" $OutputFolder = "C:\Temp\IntunePackagingScript\Output" New-IntuneWin32AppPackage -SourceFolder $SourceFolder -SetupFile $SetupFile -OutputFolder $OutputFolder -Verbose
Get MSI meta data from .intunewin file
$IntuneWinFile = "C:\Temp\IntunePackagingScript\Output\7z920-x64.intunewin" $IntuneWinMetaData = Get-IntuneWin32AppMetaData -FilePath $IntuneWinFile
Create custom display name like 'Name' and 'Version'
$DisplayName = $IntuneWinMetaData.ApplicationInfo.Name + " " + $IntuneWinMetaData.ApplicationInfo.MsiInfo.MsiProductVersion $Publisher = $IntuneWinMetaData.ApplicationInfo.MsiInfo.MsiPublisher
Create MSI detection rule
$DetectionRule = New-IntuneWin32AppDetectionRuleMSI -ProductCode $IntuneWinMetaData.ApplicationInfo.MsiInfo.MsiProductCode -ProductVersionOperator "greaterThanOrEqual" -ProductVersion $IntuneWinMetaData.ApplicationInfo.MsiInfo.MsiProductVersion
Add new MSI Win32 app
Add-IntuneWin32App -FilePath $IntuneWinFile -DisplayName $DisplayName -Description "Install 7-zip application" -Publisher $Publisher -InstallExperience "system" -RestartBehavior "suppress" -DetectionRule $DetectionRule -Verbose
The above is essentially taken from the provided example.
When I run this as is, it fails with "Cannot Index into a null array"
Doing some troubleshooting, it seems that the arrays it is having issues with are those relating to the below
"minimumFreeDiskSpaceInMB" = if ($RequirementRule["minimumFreeDiskSpaceInMB"]) { $RequirementRule["minimumFreeDiskSpaceInMB"] } else { " " }
"minimumMemoryInMB" = if ($RequirementRule["minimumMemoryInMB"]) { $RequirementRule["minimumMemoryInMB"] } else { " " }
"minimumNumberOfProcessors" = if ($RequirementRule["minimumNumberOfProcessors"]) { $RequirementRule["minimumNumberOfProcessors"] } else { " " }
"minimumCpuSpeedInMHz" = if ($RequirementRule["minimumCpuSpeedInMHz"]) { $RequirementRule["minimumCpuSpeedInMHz"] } else { " " }
When I define a RequirementRule however using the below, I have no issue $requirementRule = New-IntuneWin32AppRequirementRule -Architecture All -MinimumSupportedWindowsRelease 20H2
My Add-IntuneWin32App line now looks like the below
Add-IntuneWin32App -FilePath $IntuneWinFile -DisplayName $DisplayName -Description "Install 7-zip application" -Publisher $Publisher -InstallExperience "system" -RestartBehavior "suppress" -DetectionRule $DetectionRule -RequirementRule $requirementRule -Verbose
Not really something that needs to be fixed, I just adjusted the module on my end to make RequirementRule mandatory and its working with no issues.