Code Monkey home page Code Monkey logo

intunewin32app's People

Contributors

aaronparker avatar apcsb avatar armentpau avatar fjarlq avatar nickolaja avatar srozemuller avatar thomassteendijk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

intunewin32app's Issues

New-IntuneWin32AppReturnCode missing type "Failed"

As per the title, the New-IntuneWin32AppReturnCode module does not support the type "failed".
As a workaround, I'm currently having to manually create the hashtable with the failed type, which I'm deploying as part of the Add-IntuneWin32App deployment.

Cannot set the Scope Tag of an app when creating it

In our environment, we use Scope Tags on many objects, including Win32Apps. This module assumes the "Default" scope and fails if the person running the code does not have rights to "Default" scope. Would it be possible to add a parameter when creating an app to be able to specify the Scope Tag(s)?

Add-IntuneWin32AppAssignmentGroup has bad request

Hi,
get function is working but add function not.
version 1.3.5

Add-IntuneWin32AppAssignmentGroup -Include -ID XXXXXX -GroupID XXXXXXX -Intent available -Verbose
VERBOSE: RestartNotificationSnooze parameter was not specified, which means 'Allow user to snooze the restart notification' functionality
 will be disabled for this assignment
VERBOSE: Querying for Win32 app using ID: XXXXXX
VERBOSE: GET https://graph.microsoft.com/Beta/deviceAppManagement/mobileApps/XXXXXX
VERBOSE: Retrieving any existing Win32 app assignments to validate existing assignments for duplicate resources
VERBOSE: GET https://graph.microsoft.com/Beta/deviceAppManagement/mobileApps/XXXXXX/assignments
VERBOSE: Detected count of '0', skipping assignment validation for existence of target type: Group
VERBOSE: POST https://graph.microsoft.com/Beta/deviceAppManagement/mobileApps/XXXXXX/assignments
WARNING: Request to https://graph.microsoft.com/Beta/deviceAppManagement/mobileApps/XXXXXX/assignments fail
ed with HTTP Status BadRequest and description: Bad Request

New-IntuneWin32AppDetectionRuleScript.ps1 error in scriptcontent

error in scriptcontent (line 50)

that work at me
#$ScriptContent = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes([System.IO.File]::ReadAllBytes("$($ScriptFile)") -join [Environment]::NewLine)) $ScriptContent = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes((Get-Content -Path "$($ScriptFile)" -Raw -Encoding UTF8)))

Update the App version. Not new app, just update the App.

Does this module allow the updating of apps. For example, I have a script that checks for new version of zoom, every time there is a new verison, the script auto packages the msi into a win32 app .intunewin, then updates the intune application with the new .intunewin file, not replacing any other parameters. Thanks

Add Support for Using Network Shares for Application Sources

Would it be possible to rework the module to support network shares? I'm in a transition period of using both SCCM and Intune to push software to computers. I wrote PowerShell scripts several years ago to automatically download and deploy software in SCCM. Adding the ability to also deploy in Intune only requires an additional 6 lines of code using this module, but I can't reference the network share where I download the software installers to.

As a workaround I've commented out the FilePath parameter's "validatepattern" check and everything still appears to work.

This is what I am commenting out. It is used within several functions.

[ValidatePattern("^[A-Za-z]{1}:\\\w+")]

Get-IntuneWin32AppMetaData : Cannot validate argument on parameter 'FilePath'. The argument 7z1900-x64.intunewin" does not match the "^[A-Za-z]{1}:\\w+\\w+" pattern.

When running
New-IntuneWin32AppPackage -SourceFolder $SourceFolder -SetupFile $SetupFile -OutputFolder $OutputFolder -Verbose

it throws following error.
Get-IntuneWin32AppMetaData : Cannot validate argument on parameter 'FilePath'. The argument "D:_Intune-Win32App\7-Zip\7z1900-x64.intunewin" does not match the "^[A-Za-z]{1}:\\w+\\w+" pattern. Supply an argument that
matches "^[A-Za-z]{1}:\\w+\\w+" and try the command again.
At C:\Program Files\WindowsPowerShell\Modules\IntuneWin32App\1.1.1\IntuneWin32App.psm1:277 char:94

  • ... pMetaData = Get-IntuneWin32AppMetaData -FilePath $IntuneWinAppPackage
    • CategoryInfo : InvalidData: (:) [Get-IntuneWin32AppMetaData], ParameterBindingValidationException
    • FullyQualifiedErrorId : ParameterArgumentValidationError,Get-IntuneWin32AppMetaData

github-10jun20-01

Add support for category in Add-IntuneWin32App

I'm currently in the process of creating standard templates for common applications to run on new Intune tenants, and have found that we can't define the app category when creating the application this way - requiring us to go and set this later from the portal.

As such, this may lead to wildly different looking setups across tenants, depending on the person running the script or setting up the application - or may even lead to everything lumped into a single default category.

New-IntuneWin32AppPackage : WARNING: This command cannot be run due to the error: %1 is not a valid Win32 application

Hello,

I'm not able to generate a .intunewin file when i using the New-IntuneWin32AppPackage cmdlet.
The message appears : WARNING: This command cannot be run due to the error: %1 is not a valid Win32 application

When i check the function script "Invoke-executable"
$PackageInvocation = Invoke-Executable -FilePath $IntuneWinAppUtilPath -Arguments "-c ""$($SourceFolder)"" -s ""$($SetupFile)"" -o ""$($OutPutFolder)""" # -q
The "Else" return is not the same message

else {
Write-Warning -Message "Unexpect error occurred while packaging Win32 app. Return code from invocation: $($PackageInvocation)"
}

I think the issue come from the Invoke-Executable, because if i run manually the same command by replacing Invoke-Executable with Start-Process, it works.

Best regards

Steven

Add-inTuneWin32App Renames intunewin File

When adding an app using the add-intunewin32app cmdlet, I notice that the intunewin file is renamed to "IntunePackage.intunewin". This only occurs when using the cmdlet, but not when creating the app manually.

image

Update-IntuneWin32AppPackageFile removes App Icon

As there is no Remove-IntuneWin32App cmdlet we rely on the Update-IntuneWin32AppPackageFile cmdlet.
Now as I started to use app icons in the IntunePortal I saw the issue, that when I try to override the App with the Update cmdlet the existing Icon is gone and there is no cmdlet to add the Icon afterwards or a paramet in the update cmdlet.
Could you please look into this?

Add-IntuneWin32AppAssignmentGroup : Parameter set cannot be resolved using the specified named parameters.

Hello,

I'm currently running into the following issue trying to assign an App Assignment to a AzureAD Group:

image

These are the Parameters I am using:

Add-IntuneWin32AppAssignmentGroup -Id $IntuneWin32AppID -groupId $AzureADGroupID -Intent "available" -Verbose

These are the things I checked:

  • I checked both the App ID (using Get-IntuneWin32App) as well as the Azure AD Group ID.
  • I tried it using both PowerShell 5 and the latest version of PowerShell 7
  • I checked the other Cmdlets, such as Add-IntuneWin32App; they work just fine.
  • I checked that I'm using the latest version 1.3.3

I would greatly appreciate any help!

Best Regards,
Nico

Azure Roles Required

Thanks so much for working on these modules, my only question is around the required Azure roles needed to connect to graph. It works fine when a Global Admin (obviously) but I need to find the minimum required role assignments for the cmdlets to work. Thanks again

New-IntuneWin32AppRequirementRuleScript.ps1 error JSON type and scriptcontent

error in line 245:
can you change the line 245 from "detectionValue" = $BooleanValue" to "detectionValue" = $BooleanValue.ToString().ToLower()

            "Boolean" {
                # Construct ordered hash-table with least amount of required properties for default requirement rule
                $RequirementRuleScript = [ordered]@{
                    "@odata.type" = "#microsoft.graph.win32LobAppPowerShellScriptRequirement"
                    "operator" = $BooleanComparisonOperator
                    **"detectionValue" = $BooleanValue.ToString().ToLower()**
                    "displayName" = $ScriptFileName
                    "enforceSignatureCheck" = $EnforceSignatureCheck
                    "runAs32Bit" = $RunAs32BitOn64System
                    "runAsAccount" = $ScriptContext
                    "scriptContent" = $ScriptContent
                    "detectionType" = "boolean"
                }

https://docs.microsoft.com/de-de/graph/api/resources/intune-apps-win32lobapppowershellscriptrequirement?view=graph-rest-beta

error in line 210
#$ScriptContent = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes([System.IO.File]::ReadAllBytes("$($ScriptFile)") -join [Environment]::NewLine))
$ScriptContent = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes((Get-Content -Path "$($ScriptFile)" -Raw -Encoding UTF8)))

"HTTP Status BadRequest" when creating an application

This is an FYI, not an issue. I came across the following issue when using version 1.3.5 of the module (this wasn't an issue with 1.3.3).

The following is logged when creating a package for Microsoft Teams MSI installer:

VERBOSE: Successfully created Win32 app package object
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.

Notice that in my App.json which defines the Microsoft Teams package, it has the following details, which includes the (em dash) character in the description. The creation of the package was falling over on this character - after removing this, the package was created successfully.

  "Information": {
    "DisplayName": "Microsoft Teams 1.5.00.21668 x64",
    "Description": "More is possible with Microsoft Teams. Stay connected and access shared content any time to learn, plan, and innovate—together.",
    "Publisher": "Microsoft",
    "InformationURL": "https://www.microsoft.com/microsoft-teams/",
    "PrivacyURL": "https://go.microsoft.com/fwlink/?LinkId=521839"
  }

Note though, this might be fixed with Utf8 support #10

Add-IntuneWin32AppSupersedence rewrite supersedence

I did small change in source code. I need add next supersedence and not update.
It is same problem as about depencies.
I dont want open next issue. How fix this issue?
version 1.3.5

function Add-IntuneWin32AppSupersedence {
    [CmdletBinding(SupportsShouldProcess = $true)]
    param(
        [parameter(Mandatory = $true, HelpMessage = "Specify the ID for an existing Win32 application where supersedence will be configured.")]
        [ValidateNotNullOrEmpty()]
        [string]$ID,
        
        [parameter(Mandatory = $true, HelpMessage = "Specify the ID2 for an existing Win32 application where supersedence will be configured.")]
        [ValidateNotNullOrEmpty()]
        [string]$ID2,

        [parameter(Mandatory = $true, HelpMessage = "Specify the supersedence behavior, use Replace for uninstall and Update for when updating an app.")]
        [ValidateNotNullOrEmpty()]
        [ValidateSet("Replace", "Update")]
        [string]$SupersedenceType

        #[parameter(Mandatory = $true, HelpMessage = "Provide an array of a single or multiple OrderedDictionary objects created with New-IntuneWin32AppSupersedence function.")]
        #[ValidateNotNullOrEmpty()]
        #[System.Collections.Specialized.OrderedDictionary[]]$Supersedence
    )
         # Retrieve Win32 app by ID from parameter input
        Write-Verbose -Message "Querying for Win32 app using ID: $($ID2)"
        $Win32App2 = Invoke-IntuneGraphRequest -APIVersion "Beta" -Resource "mobileApps/$($ID2)" -Method "GET"
        if ($Win32App2 -ne $null) {
            $Win32AppID2 = $Win32App2.id

               
        # Retrieve Win32 app by ID from parameter input
        Write-Verbose -Message "Querying for Win32 app using ID: $($ID)"
        $Win32App = Invoke-IntuneGraphRequest -APIVersion "Beta" -Resource "mobileApps/$($ID)" -Method "GET"
        if ($Win32App -ne $null) {
            $Win32AppID = $Win32App.id

            # Check for existing relations for Win32 app, supersedence and dependency configurations cannot co-exist currently
            $Win32AppDependencyExistence = Get-IntuneWin32AppRelationExistence -ID $Win32AppID -Type "Dependency"
            if ($Win32AppDependencyExistence -eq $false) {
                # Validate that Win32 app where supersedence is configured, is not passed in $Supersedence variable to prevent an app superseding itself
                if ($Win32AppID -notin $Supersedence.targetId) {
                        
                    # Construct supersedence table
                    $Supersedence = [ordered]@{
                        "@odata.type" = "#microsoft.graph.mobileAppSupersedence"
                        "supersedenceType" = $SupersedenceType.ToLower()
                        "targetId" = $Win32AppID
                    }


                    $Win32AppRelationships = [ordered]@{
                        "relationships" = @($Supersedence)
                    }

                    try {
                        # Attempt to call Graph and configure supersedence for Win32 app
                        Invoke-IntuneGraphRequest -APIVersion "Beta" -Resource "mobileApps/$($Win32AppID)/updateRelationships" -Method "POST" -Body ($Win32AppRelationships | ConvertTo-Json) -ErrorAction Stop
                    }
                    catch [System.Exception] {
                        Write-Warning -Message "An error occurred while configuring supersedence for Win32 app: $($Win32AppID). Error message: $($_.Exception.Message)"
                    }
                }
                else {
                    $SupersedenceItems = -join@($Supersedence.targetId, ", ")
                    Write-Warning -Message "A Win32 app cannot be used to supersede itself, please specify a valid array or single object for supersedence"
                    Write-Warning -Message "Win32 app with ID '$($Win32AppID)' is set as parent for supersedence configuration, and was also found in child items: $($SupersedenceItems)"
                }
            }
            else {
                Write-Warning -Message "Existing dependency relation configuration exists for Win32 app, supersedence is not allowed to be configured at this point"
            }
        }
        else {
            Write-Warning -Message "Query for Win32 app returned an empty result, no apps matching the specified search criteria with ID '$($ID)' was found"
        }
    }
    else {
      Write-Warning -Message "Query for Win32 app returned an empty result, no apps matching the specified search criteria with ID '$($ID2)' was found"
    }
}

Error message: Cannot validate argument on parameter 'Body'.

Have created an 3.2 gb intunewin file and creating the app with :

Add-IntuneWin32App -FilePath $IntuneWinFile.Path -DisplayName $DisplayName -Description $DisplayName -Publisher $appVendor -InstallExperience system -RestartBehavior suppress -DetectionRule $DetectionRule -RequirementRule $RequirementRule -InstallCommandLine $InstallCommandLine -UninstallCommandLine $UninstallCommandLine -Icon $Icon -Verbose

It starts :

VERBOSE: Current authentication token expires in (minutes): 16                                                                                                                                          
VERBOSE: Attempting to gather additional meta data from .intunewin file: C:\temp\AutoCAD_Architecture_2021\Deploy-Application.intunewin                                                                 
VERBOSE: Successfully gathered additional meta data from .intunewin file                                                                                                                                
VERBOSE: Start constructing basic layout of Win32 app body                                                                                                                                              
VERBOSE: Constructed the basic layout for 'EXE' Win32 app body type                                                                                                                                     
VERBOSE: Detection rule objects passed validation checks, attempting to add to existing Win32 app body                                                                                                  
VERBOSE: Retrieving default set of return codes for Win32 app body construction                                                                                                                         
VERBOSE: Adding array of return codes to Win32 app body construction                                                                                                                                    
VERBOSE: Attempting to create Win32 app using constructed body converted to JSON content                                                                                                                
VERBOSE: POST https://graph.microsoft.com/Beta/deviceAppManagement/mobileApps                                                                                                                          
VERBOSE: Successfully created Win32 app with ID: ac10fde8-8ee6-40e0-87c4-b5511dc87133                                                                                                                   
VERBOSE: Attempting to create contentVersions resource for the Win32 app                                                                                                                                
VERBOSE: POST https://graph.microsoft.com/Beta/deviceAppManagement/mobileApps/***-8ee6-40e0-87c4-b5511dc87133/microsoft.graph.win32LobApp/contentVersions                                          
VERBOSE: Successfully created contentVersions resource with ID: 1                                                                                                                                       
VERBOSE: Constructing Win32 app content file body for uploading of .intunewin file                                                                                                                      
VERBOSE: POST https://graph.microsoft.com/Beta/deviceAppManagement/mobileApps/***-8ee6-40e0-87c4-b5511dc87133/microsoft.graph.win32LobApp/contentVersions/1/files                                  
VERBOSE: Waiting for Intune service to process contentVersions/files request 
.....
2 min later:
.....
VERBOSE: Uploading file to Azure Storage blob, processing chunk '264' of '526'
VERBOSE: PUT
https://***.blob.core.windows.net/*-c771-44b5-97c7-67fc43cf0b9f/*-70cf-463b-9637-9d85819b1bec/***-7b01-4f4e-b01f-cc74d5ac1519.intunewin.bin?sv=2016-05-31&sr=b&si=-62917231&si
g=****=&comp=block&blockid=MDI2Mw== with -1-byte payload
VERBOSE: received 0-byte response of content type
WARNING: An error occurred while creating the Win32 application. Error message: Cannot validate argument on parameter 'Body'. The argument is null or empty. Provide an argument that is not null or
empty, and then try the command again.```


All variables has working values.
App is created in Intune, Settings seems ok,  but "Your app is not ready yet. If app content is uploading.. 

(Get-IntuneWin32AppMetaData -FilePath Deploy-Application.intunewin).ApplicationInfo  =

xsd : http://www.w3.org/2001/XMLSchema
xsi : http://www.w3.org/2001/XMLSchema-instance
ToolVersion : 1.4.0.0
Name : Deploy-Application.exe
UnencryptedContentSize : 3304008521
FileName : IntunePackage.intunewin
SetupFile : Deploy-Application.exe
EncryptionInfo : EncryptionInfo

Version 1.2.0
edit: Forgot to mention that it stops on diffrent chunks each time.. the upload works in browser upload to intune. 
Any Ideas ?
 

New-IntuneWin32AppIcon - does not match the "^[A-Za-z]{1}:\\\w+\\\w+" pattern.

Hi,
New-IntuneWin32AppIcon : Cannot validate argument on parameter 'FilePath'. The argument "D:\Gimp\gimp1.png" does not match the "^[A-Za-z]{1}:\\w+\\w+" pattern. Supply an
argument that matches "^[A-Za-z]{1}:\\w+\\w+" and try the command again.
At line:2 char:42

  • $Icon = New-IntuneWin32AppIcon -FilePath $ImageFile

Any help would be much appreciated, thank you.

Issue with defining multiple requirements via New-IntuneWin32AppRequirementRule

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?

Authentication issue after updating to Module 1.3.2

Hi,
i used to use Moduleversion 1.2.1 before and upgraded to 1.3.2.
Now I get the following error Message:
Connect-MSIntuneGraph -TenantID $tenantID
"WARNING: An error occurred while attempting to retrieve or refresh access token. Error message: The property 'Authority' cannot be found on this object. Verify that the property exists."

It is the same user which I used for connection with 1.2.1.
Do you have any hints what the reason could be?

Access to the cloud file is denied

The Error is: WARNING: An error occurred while creating the Win32 application. Error message: Access to the cloud file is denied

The problem does appear wherever the consent is on behalf of the user or organization. But i do not have the behavior in every tenant.
When this happens, the App is uploaded and looks fine, but when trying to install nothing happens and the app shows as installed immediately.
After manually uploading the detection-script file it works.

Issue with Authentication Header Using LocalTime and AccessToken Using UTC

When running connect-msintunegraph the variable $global:authenticationheader has the property of expireson in local time. When functions such as Add-IntuneWin32App are called, the code to ensure required authentication header variable exists runs the following:
$TokenLifeTime = ($Global:AuthenticationHeader.ExpiresOn - (Get-Date).ToUniversalTime()).Minutes

This converts the current date time to UTC, with the value from the variable in local time, resulting in a negative time frame (in my case - 4 hours, -58 mins) at my current time

I can correct this while developing my pipeline currently by running the following:

$global:authenticationheader.expireson = $global:authenticationheader.expireson.touniversaltime()

It looks like updating the code in New-AuthenticationHeader to the below should resolve the issue:

$AuthenticationHeader = @{ "Content-Type" = "application/json" "Authorization" = $AccessToken.CreateAuthorizationHeader() "ExpiresOn" = $AccessToken.ExpiresOn.UtcDateTime }

-whatif switch for Add-IntuneWin32AppAssignmentGroup gets ignored

The Command was
Add-IntuneWin32AppAssignmentGroup -ID $AppID -GroupID $GroupID -Intent required -Notification showAll -Include -WhatIf
This actually creates the assignment instead of just pretending to.
Expected Behaviour:
Whatif: Adding Assignment for AppID with GroupID

Authentication issue

When running Connect-MSIntuneGraph -TenantName "aaa.onmicrosoft.com", and at a later stage Connect-MSIntuneGraph -TenantName "bbb.onmicrosoft.com", the new token does refreshed correctly to connect to the new tenant. I.e. it still connect to the "aaa.onmicrosoft.com"-tenant.
Running Connect-MSIntuneGraph with -PromptBehavior Always works, but then you have to authenticate every time.

Requirements Rule somewhat mandatory now since latest release

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.

[Category] setting does not exist

Thank you for amazing tool!

Would it be possible to add the [Category] setting for Win32 apps?

Right now, we are trying to use IntuneWin32App in order to create big amounts of apps all at once.
Although, when setting an app to be pulled, we would like to make it easier for the users to find the app they need on the portal site by setting [Category], the setting of Win32([App information]- [Category]) does not exist on IntuneWin32App(see the image below).
We would appreciate it if you could add the feature and help us solve this problem.
・Add-IntuneWin32App.ps1
・Get-IntuneWin32App.ps1
Intune_Category

Character encoding is wrong

Using language specific letters like æ ø å (DK), is not working. Showing random symbols instead. Encoding in UTF-8 should fix it.

Inconsistent use of GroupName and GroupId

Add-IntuneWin32AppAssignmentGroup uses -GroupId parameter and Get-IntuneWin32AppAssignment uses the -GroupName parameter instead.

My suggestion is to handle both GroupId and GroupName options in both.

Update-IntuneWin32AppPackageFile error if working dir on onedrive folder

function Update-IntuneWin32AppPackageFile
line 152:
Remove-Item -Path (Split-Path -Path $IntuneWinFilePath -Parent) -Recurse -Force -Confirm:$false | Out-Null
on onedrive cant remove dir with remove-item and stop with error

this function is a workaround to delete file and dirs on onedrive:

function Remove-Dir {
param(
$Path
)
try {
if (Test-Path -Path $Path -PathType Container) {
#workaround detete on Onedrive Folders
Get-ChildItem -Path $Path -File -Recurse | remove-item -Force
$dirs = Get-ChildItem -Path $Path -Recurse
$i = $dirs.Count - 1
for ($i; $i -ge 0; $i--) { $dirs[$i].Delete($true) }
(get-item -Path $Path).Delete($true)
Write-Host "Delete dir ($Path)."
}
}
catch {
Write-Error "Delete dir ($Path) failed! ($_)"
return $false
}

}

New-IntuneWin32AppRequirementRule don't respect MinimumFreeDiskSpaceInMB parameter

Hello!

I see, that I can't add requirement, based on MinimumFreeDiskSpaceInMB:

$RequirementRules = New-IntuneWin32AppRequirementRule -Architecture All -MinimumSupportedOperatingSystem 1607 `
  -MinimumFreeDiskSpaceInMB $MinimumFreeDiskSpaceInMB

...

$Application = Add-IntuneWin32App -FilePath $IntuneWinFile.Path -DisplayName $DisplayName `
                  -Description $Description -Publisher $Publisher -InstallExperience "system" `
                  -RestartBehavior "suppress" -DetectionRule $DetectionRules `
                  -RequirementRule $RequirementRules -InstallCommandLine $InstallCommandLine `
                  -UninstallCommandLine $UninstallCommandLine `
                  -Icon $Icon -Notes $Notes -Owner $Owner -Developer $Developer `
                  -AppVersion $AppVersion -InformationURL $InformationURL

Library version: 1.3.3

But in Endpoint this field still empty. Can you help me with it?

Best regards

Update-IntuneWin32AppPackageFile error handling

The Update-IntuneWin32AppPackageFile module doesn't error out when it fails to upload the file.
I use this in a script to update my applications and when the API bugs out, it just throws a warning and continues when really, it should throw.
I can work around it by using the -WarningAction flag, but really based on my experience, most of the "Write-Warning" lines should be "Write-Error", but maybe I'm missing something...

Run without MSAL

I don't have MSAL and I don't need it ATM., so I made a parameter called -SkipMSAL.

Changes is in the following files:

Private/New-AuthenticationHeader.ps1
Public/Connect-MSIntuneGraph.ps1

I got this error, without MSAL:
WARNING: An error occurred while attempting to retrieve or refresh access token.

Error message: The term 'Get-MsalToken' is not recognized as the na
me of a cmdlet, function, script file, or operable program.

Check the spelling of the name, or if a path was included, verify that the path is corre
ct and try again.

new parameter MinimumSupportedWindowsRelease not work in version 1.3.5

Bad JSON request

function New-IntuneWin32AppRequirementRule

can u change line 92:
form
"minimumSupportedWindowsRelease" = $OperatingSystemTable[$MinimumSupportedWindowsRelease]
to
"minimumSupportedWindowsRelease" = "$($OperatingSystemTable[$MinimumSupportedWindowsRelease])"

that work fine for me

thanks

Cannot add an app with a New-IntuneWin32AppRequirementRuleRegistry. error

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

Schermafbeelding 2022-04-27 203251

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.

Schermafbeelding 2022-04-27 203538

It just bombs out whenever I switch to a New-IntuneWin32AppRequirementRuleRegistry.

Schermafbeelding 2022-04-27 203420

Tried almost everything, so no idea what I am doing wrong here

New-IntuneWin32AppDetectionRuleScript.ps1 Corrupted Detection Scripts on converting to Base64

Using non-utf encoding of multi-character line scripts breaks when imported into Intune.

I change line 49 from:
$ScriptContent = [System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes("$($ScriptFile)"))

to:

$ScriptContent = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($(get-content $ScriptFile) -join [Environment]::NewLine))

To resolve this. I'll submit a PR later after some more tesitng.

Add-IntuneWin32AppAssignmentGroup Error on setting Restart

It is not possible to use Add-IntuneWin32AppAssignmentGroup to mimic the same thing that is allowed via the console.

When trying to use:
Add-IntuneWin32AppAssignmentGroup -Include -ID SOMEID -GroupID SOMEGROUPID -Intent available -Notification showAll
DeliveryOptimizationPriority foreground -EnableRestartGracePeriod $true -RestartGracePeriod 180 -RestartCountDownDisplay 15

The following warning is displayed:
WARNING: Win32 app was not configured for restart settings, ensure restart behavior is configured with 'Based on return code'

It is forcing use of "Device Restart Behavior" setting of "Determine Behavior based on return codes". But when creating the assignment with the console, I am successfully able to create the assignment with a "Device Restart Behavior" = "No Specific Action".

I was able manually update the code and remove the dependency on return codes. Doing that allowed a successful creation of the assignment.

Update-IntuneWin32AppPackageFile

Hi,
would it be possible to extend the function, so that you can change the detection rule within the update process, or is it planed that there is an extra update function for this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.