Skip to content

rgertech/intune

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Excellent question. This is a very common scenario. Since the file is already on the laptop, you don't need Intune to deliver the file, just to execute the installation command.

The best and most modern method to do this in Intune is to package the installer as a Win32 App. This gives you superior reporting, dependency handling, and detection logic compared to a simple script.

Here’s a step-by-step guide for both the recommended method and a fallback script method.


Method 1: Recommended - Package as a Win32 App

This method treats your installer like a formal application, which is Intune's preferred approach.

Step 1: Prepare the "Content" Folder

Even though the file is on the end-user's laptop, Intune needs a "source" for the app. You'll create a simple package.

  1. Create a new folder on your computer (e.g., Action1_Package).
  2. Inside this folder, create a simple PowerShell script or a batch file that will run the installer. Let's use a batch file for simplicity.
    • Create a new text file and name it Install_Action1.cmd.
  3. Edit this .cmd file and put the following command in it:
    start /wait %~dp0action1.exe /S
    • %~dp0 means "the drive and path of this batch file". This tells the command to look for action1.exe in the same directory as the script.
    • /S is a common silent install switch. You must find the correct silent install command-line parameter for Action1. It might be /quiet, -silent, etc. Check Action1's documentation. The /S is just a common example.

Step 2: Use the Microsoft Win32 Content Prep Tool

This tool packages your folder into the .intunewin format Intune requires.

  1. Download the Microsoft Win32 Content Prep Tool from GitHub.
  2. Run the tool (IntuneWinAppUtil.exe).
  3. When prompted:
    • Source folder: Enter the path to your Action1_Package folder.
    • Setup file: Enter the name of your installer script: Install_Action1.cmd.
    • Output folder: Choose a destination for the .intunewin file.
  4. The tool will create a single .intunewin file (e.g., Action1_Package.intunewin).

Step 3: Create the App in Intune

  1. Go to the Microsoft Intune admin center.
  2. Navigate to Apps > All apps > Add.
  3. Under App type, select Windows app (Win32).
  4. Click Select.
  5. App information: Upload the .intunewin file and enter details like Name, Description, and Publisher (e.g., "Action1").
  6. Program: This is the core configuration.
    • Install command: Install_Action1.cmd
    • Uninstall command: (Provide one if available, e.g., "%ProgramFiles%\Action1\uninstall.exe" /S or leave blank).
    • Install behavior: System
  7. Requirements: Select the appropriate OS architecture (e.g., 64-bit) and minimum OS version.
  8. Detection rules: This is critical. You need a rule so Intune knows if the app is already installed.
    • Rules format: Manually configure format
    • Rule type: Choose the best method:
      • File: Check if C:\Program Files\Action1\action1.exe exists.
      • Registry: Check for a specific key, e.g., HKEY_LOCAL_MACHINE\SOFTWARE\Action1 with a specific version.
      • MSI: If Action1 uses an MSI, you can use the product code.
  9. Assignments: Assign the app to the required device group containing your laptops. Set the assignment to Required.
  10. Complete the wizard.

The laptops will check in with Intune, see the "Required" assignment, and execute the installation command from the local file.


Method 2: Fallback - Use a PowerShell Script

If packaging as a Win32 app seems too complex for a one-off task, a simple PowerShell script will work.

Step 1: Create the PowerShell Script

  1. Create a new file named Install-Action1.ps1.

  2. Put the following code inside it. You will need to adjust the path to action1.exe and the silent install switch.

    # Define the path to the local Action1 installer
    $InstallerPath = "C:\Path\To\The\Downloaded\action1.exe"
    
    # Check if the installer file exists
    if (Test-Path $InstallerPath) {
        Write-Output "Installer found at $InstallerPath. Beginning installation..."
        
        # Run the installer silently. CHANGE /S TO THE CORRECT SWITCH!
        $InstallProcess = Start-Process -FilePath $InstallerPath -ArgumentList "/S" -Wait -PassThru
    
        # Check the exit code
        if ($InstallProcess.ExitCode -eq 0) {
            Write-Output "Action1 installed successfully."
            exit 0 # Exit code 0 tells Intune the script was successful
        } else {
            Write-Output "Installation failed with exit code: $($InstallProcess.ExitCode)"
            exit 1 # Exit code 1 tells Intune the script failed
        }
    } else {
        Write-Output "ERROR: Installer not found at $InstallerPath."
        exit 1
    }

Step 2: Deploy the Script in Intune

  1. Go to the Microsoft Intune admin center.
  2. Navigate to Devices > Scripts > Add > Windows 10 and later.
  3. Basics: Give it a name, e.g., "Install Local Action1".
  4. Settings: Upload your Install-Action1.ps1 file.
    • Run this script using the logged on credentials: No
    • Enforce script signature check: No
    • Run script in 64 bit PowerShell Host: Yes
  5. Assignments: Assign the script to the device group containing your laptops.
  6. Review and add.

Critical Success Factors & Which Method to Choose

Factor Win32 App (Method 1) PowerShell Script (Method 2)
Reporting Excellent. Clear "Installed/Failed" status. Basic. Shows "Succeeded" if script runs, even if install fails.
Reliability High. Has built-in detection logic to prevent re-installs. Lower. Will run the script every time, which could re-run the installer.
Retry Logic Yes. Intune will retry failed installations. Limited.
Complexity More steps to set up initially. Quicker to set up for a simple task.
Best For Production environments, reliable reporting. Quick one-off tasks, testing.

Recommendation: Use Method 1 (Win32 App). It is the more robust, manageable, and "correct" way to handle software installation in a modern management system like Intune. The initial setup is worth it for the superior control and reporting you get.

About

Use Microsoft intune to deploy or run scripts on remote laptops?

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published