Pages

Sunday, 14 January 2024

Intune win32 app Create,Upload and deployment 1.0

 


#==================================================================================================================
#Dont change anything until new version of module released
# Install IntuneWin32App module from PowerShellGallery
# - Required modules:
# -- MSAL.PS (installed automatically)
$moduleName = "IntuneWin32App"
$moduleVersion = "1.4.3"  # Replace this with the version you want
$installedModule = Get-InstalledModule -Name $moduleName -ErrorAction SilentlyContinue

if (!$installedModule) {
    Write-Host "Installing $moduleName module..."
    Install-Module -Name $moduleName -RequiredVersion $moduleVersion -Force -Confirm:$false
    Write-Host "$moduleName module installed successfully."
} elseif ($installedModule.Version -lt $moduleVersion) {
    Write-Host "Updating $moduleName module to version $moduleVersion..."
    Update-Module -Name $moduleName -RequiredVersion $moduleVersion -Force
    Write-Host "$moduleName module updated successfully to version $moduleVersion."
} else {
    Write-Host "$moduleName module already installed and up-to-date."
}
Get-Command -Module "IntuneWin32App"
#==================================================================================================================
#.Intunewinfile will create Automatically if we give source location, Inatsll command and output folder

# Package MSI as .intunewin file
$SourceFolder = "C:\Temp\Notepad++ org\Notepad++\7.89\SourceFile"
$SetupFile = "Deploy-Application.exe"
$OutputFolder = "C:\Temp\Notepad++ org\Notepad++\7.89\IntuneFile"
$IntuneWinAppUtilPath = "C:\Temp\IntuneWinAppUtil.exe"

# Check if IntuneWinAppUtil.exe exists
if (Test-Path $IntuneWinAppUtilPath -PathType Leaf) {
    # Create the IntuneWin package
    & $IntuneWinAppUtilPath -c $SourceFolder -s $SetupFile -o $OutputFolder -q
    Write-Host "IntuneWin package created successfully."
} else {
    Write-Host "Error: IntuneWinAppUtil.exe not found at $IntuneWinAppUtilPath."
}
#New-IntuneWin32AppPackage -SourceFolder $SourceFolder -SetupFile $SetupFile -OutputFolder $OutputFolder -Verbose

#==================================================================================================================

#This function will get the App Information automatically from the folder
function Get-AppInfoFromFolder {
    param (
        [string]$IntuneFile
    )

    if ($IntuneFile -match '\\([^\\]+)\\([^\\]+)\\(\d+\.\d+)[\\]IntuneFile\\Deploy-Application\.intunewin') {
        $PublisherName = $matches[1]
         $appName = $matches[2]
        $appVersion = $matches[3]
        # Use the folder name as the application name
        return [PSCustomObject]@{
            PublisherName = $PublisherName
            ApplicationName = $appName
            Version = $appVersion
        }
    } else {
        return $null
    }
}

# Explore the module


Connect-MSIntuneGraph -TenantID "pavantechie.onmicrosoft.com" -Verbose

############################################################################
#$Category are as per my tennent Test Applications,Pavan test,Other Apps,Books & Reference,Data Management,Productivity,Business,Development & Design,Photos & Media,Collaboration & Social,Computer Management
####################################################
# Sample Win32 Application
####################################################
# Please create the folder name as below
# "\\networkshre\**\**\VendorName\ApplicationName\AppVersion\IntuneFile\Deploy-Application.intunewin"
$IntuneFile = Get-ChildItem -Path $OutputFolder -Filter "*.intunewin" | Select-Object -ExpandProperty FullName
#$IntuneFile = "C:\Temp\Notepad++ org\Notepad++\7.89\IntuneFile\Deploy-Application.intunewin"
$Category = "Development & Design"
$owner = "Pavan Kalyan"  #Change as per your requirement
$url = "https://notepad-plus-plus.org/downloads/"
$installcommandline = "Deploy-Application.exe"  #Change as per your Command Line
$uninstallcommandline = "Deploy-Application.exe -Deploymenttype Uninstall" #Change as per your Command Line
$ImageFile = "C:\Temp\Notepad++ org\Notepad++\7.89\Icon\Notepad_plus_plus.png"  ## Change as per your logo location
$DetectionScriptFile = "C:\Temp\Notepad++ org\Notepad++\7.89\DetectionRule\DetectionRule.ps1"  # Change your detection script location
$RequirementRule = New-IntuneWin32AppRequirementRule -Architecture x64 -MinimumSupportedWindowsRelease W10_20H2  # CHange as per your requirement
$GroupID = "682d3c05-0247-4ab4-be52-f523cfeb5f3e" #Please put ObjectID of the group
#####################################################################



$appInfo = Get-AppInfoFromFolder -IntuneFile $IntuneFile

$displayName = $($appInfo.ApplicationName)
$publisherName = $($appInfo.PublisherName)
$appversion = $($appInfo.Version)
$appname = "${publisherName}_${displayName}_${appversion}"
$Description = "Latest version of '$appname' is available and ready for deploy"

$Icon = New-IntuneWin32AppIcon -FilePath $ImageFile

# Create PowerShell script detection rule

$DetectionRule = New-IntuneWin32AppDetectionRuleScript -ScriptFile $DetectionScriptFile -EnforceSignatureCheck $false -RunAs32Bit $false

Add-IntuneWin32app -FilePath "$IntuneFile" -DisplayName "$appname" -Description "$Description" -Publisher "$publisherName" -AppVersion "$appversion" -Developer "$publisherName" -Owner "$owner" -Notes "Not Available" -InformationURL "$url" -PrivacyURL "$url" -InstallCommandLine "$installcommandline" -UninstallCommandLine "$uninstallcommandline" -InstallExperience "system" -RestartBehavior "suppress" -MaximumInstallationTimeInMinutes "60" -DetectionRule $DetectionRule -RequirementRule $RequirementRule -Icon $icon -CategoryName "$Category" -Verbose


# Get a specific Win32 app by it's display name
$Win32App = Get-IntuneWin32App -DisplayName "$appname" -Verbose

# Add an include assignment for a specific Azure AD group
Add-IntuneWin32AppAssignmentGroup -Include -ID $Win32App.id -GroupID "$GroupID" -Intent "available" -Notification "showAll" -Verbose

No comments:

Post a Comment

User based detection

function getloggedindetails () {     ##Find logged in username     $user = Get-WmiObject Win32_Process - Filter "Name='explorer...

Search This Blog