Skip to content

UniverseCitiz3n/Intune-App-Sandbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

70 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Intune-App-Sandbox

PowerShell Gallery Version PowerShell Gallery Downloads License

πŸ§ͺ Test your Intune Win32 app deployment packages locally using Windows Sandbox before deploying to production.

A PowerShell module that enables you to pack and test Win32 Content Prep Tool packages (.intunewin) in an isolated Windows Sandbox environmentβ€”no need to deploy to actual devices during development.

✨ Features

  • One-click packaging β€” Right-click any folder to create .intunewin packages
  • Isolated testing β€” Run packages in Windows Sandbox without affecting your system
  • SYSTEM context execution β€” Scripts run as SYSTEM user, mimicking real Intune deployments
  • PSADT support β€” Automatic detection of PowerShell App Deployment Toolkit (v3 & v4) packages
  • Exit code capture β€” Retrieve $LASTEXITCODE from script execution for validation
  • Toast notifications β€” Visual progress feedback inside the Sandbox

πŸ“‹ Prerequisites

  • Windows 10/11 Pro, Enterprise, or Education
  • PowerShell 5.1 or later
  • Administrator privileges
  • Windows Sandbox feature (will be enabled automatically if not already)

πŸš€ Installation

Install from PowerShell Gallery

Install-Module -Name Intune-App-Sandbox

Initial Setup

Run the setup wizard to configure context menu integration:

Add-SandboxShell

This will:

  1. Enable the Windows Sandbox feature (if needed)
  2. Create the operating folder at C:\SandboxEnvironment
  3. Download the latest IntuneWinAppUtil.exe from Microsoft
  4. Add right-click context menu options

You can choose which context menu items to install:

Option Description
Run test in Sandbox Test .intunewin files in Windows Sandbox
Pack with IntunewinUtil Package folders into .intunewin format
Both Install both options (recommended)

πŸ”„ Updating

Update-Module -Name Intune-App-Sandbox
Update-SandboxShell

πŸ“– Usage

Packaging a Script

  1. Create a folder with the same name as your install script:

    πŸ“ Install-VSCode/
        πŸ“„ Install-VSCode.ps1
        πŸ“„ VSCodeSetup.exe
        πŸ“„ config.json
    
  2. Right-click the folder β†’ Pack with IntunewinUtil

  3. The .intunewin file is created in the same folder

Pack

Testing a Package

  1. Right-click the .intunewin file β†’ Run test in Sandbox

  2. Windows Sandbox launches and executes your script as SYSTEM

  3. Review the results in the Sandbox environment

Test

PSADT Package Support

The module automatically detects PowerShell App Deployment Toolkit packages:

Package Type Detection Setup File
PSADT v3 Folder name contains PSADT Deploy-Application.exe
PSADT v4 Folder name contains PSADTv4 Invoke-AppDeployToolkit.exe
Standard Any other folder <FolderName>.ps1

βš™οΈ How It Works

Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        HOST MACHINE                             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Right-click .intunewin                                         β”‚
β”‚         β”‚                                                       β”‚
β”‚         β–Ό                                                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ Invoke-Test.ps1 │───▢│ Generate .wsb configuration file β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                    β”‚                            β”‚
β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                            β”‚
β”‚         β–Ό                                                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                    WINDOWS SANDBOX                          β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚β”‚
β”‚  β”‚  β”‚ 1. Decode .intunewin using IntuneWinAppUtilDecoder    β”‚  β”‚β”‚
β”‚  β”‚  β”‚ 2. Extract package contents to C:\Temp                β”‚  β”‚β”‚
β”‚  β”‚  β”‚ 3. Create scheduled task running as SYSTEM            β”‚  β”‚β”‚
β”‚  β”‚  β”‚ 4. Execute install script                             β”‚  β”‚β”‚
β”‚  β”‚  β”‚ 5. Capture $LASTEXITCODE to file                      β”‚  β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Sandbox Configuration

A .wsb file is dynamically generated with:

<Configuration>
  <VGpu>Enable</VGpu>
  <Networking>Enable</Networking>
  <MappedFolders>
    <MappedFolder>
      <HostFolder>C:\Path\To\Your\Package</HostFolder>
      <ReadOnly>true</ReadOnly>
    </MappedFolder>
    <MappedFolder>
      <HostFolder>C:\SandboxEnvironment\bin</HostFolder>
      <ReadOnly>true</ReadOnly>
    </MappedFolder>
  </MappedFolders>
  <LogonCommand>
    <Command>powershell.exe -WindowStyle Hidden -noprofile -executionpolicy bypass -Command ...</Command>
  </LogonCommand>
</Configuration>

SYSTEM Context Execution

The module uses a scheduled task to run scripts as the SYSTEM userβ€”the same context Intune uses for Win32 app deployments:

# Nested PowerShell captures exit code
$Action = New-ScheduledTaskAction -Execute "powershell.exe" `
    -Argument '-ex bypass "powershell {& C:\Temp\Install.ps1};New-Item C:\Temp\$Lastexitcode.code -force"'

This nested approach ensures $LASTEXITCODE is captured correctly and saved to a file for verification.

πŸ“ File Structure

C:\SandboxEnvironment\
└── bin\
    β”œβ”€β”€ IntuneWinAppUtil.exe        # Microsoft Win32 Content Prep Tool
    β”œβ”€β”€ IntuneWinAppUtilDecoder.exe # Package decoder for Sandbox
    β”œβ”€β”€ Invoke-IntunewinUtil.ps1    # Packing script
    β”œβ”€β”€ Invoke-Test.ps1             # Test orchestration script
    β”œβ”€β”€ New-WSBConfig.ps1           # Sandbox config generator
    β”œβ”€β”€ New-LogonScriptContent.ps1  # Logon script generator
    β”œβ”€β”€ New-ToastNotification.ps1   # Toast notification helper
    └── toast.xml                   # Toast notification template

πŸ› Troubleshooting

Issue Solution
Context menu not appearing Run Add-SandboxShell as Administrator
Sandbox won't start Ensure Windows Sandbox feature is enabled
Package fails to decode Verify the .intunewin file is not corrupted
Script not executing Check that folder name matches script name

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘€ Author

Maciej Horbacz (@UniverseCitiz3n)


⭐ If this project helps you, consider giving it a star!