{"id":14063875,"url":"https://github.com/UniverseCitiz3n/Intune-App-Sandbox","last_synced_at":"2025-07-29T16:34:35.290Z","repository":{"id":46701850,"uuid":"271206779","full_name":"UniverseCitiz3n/Intune-App-Sandbox","owner":"UniverseCitiz3n","description":null,"archived":false,"fork":false,"pushed_at":"2023-10-25T10:01:48.000Z","size":4499,"stargazers_count":32,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-14T07:05:51.792Z","etag":null,"topics":["intune","powershell","win32","windows-sandbox"],"latest_commit_sha":null,"homepage":"https://www.powershellgallery.com/packages/Intune-App-Sandbox","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/UniverseCitiz3n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-10T07:18:32.000Z","updated_at":"2024-07-21T06:34:15.000Z","dependencies_parsed_at":"2022-08-12T13:00:55.128Z","dependency_job_id":null,"html_url":"https://github.com/UniverseCitiz3n/Intune-App-Sandbox","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniverseCitiz3n%2FIntune-App-Sandbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniverseCitiz3n%2FIntune-App-Sandbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniverseCitiz3n%2FIntune-App-Sandbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniverseCitiz3n%2FIntune-App-Sandbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UniverseCitiz3n","download_url":"https://codeload.github.com/UniverseCitiz3n/Intune-App-Sandbox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228032914,"owners_count":17858914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["intune","powershell","win32","windows-sandbox"],"created_at":"2024-08-13T07:03:33.108Z","updated_at":"2024-12-04T02:30:42.039Z","avatar_url":"https://github.com/UniverseCitiz3n.png","language":"PowerShell","funding_links":[],"categories":["PowerShell"],"sub_categories":[],"readme":"# Intune-App-Sandbox\n\nThis tool is for testing Powershell Script which is packed using [Win32 Content Prep Tool](https://github.com/microsoft/Microsoft-Win32-Content-Prep-Tool) for installing software using Win32 Deployment profile in Intune.\n\n# Installing\n\nProject is published to `PSGallery`.\n```powershell\nInstall-Module -Name Intune-App-Sandbox\n```\nTo configure tool on your device run `Add-SandboxShell`.\n\nIt will create folder - `C:\\SandboxEnvironment` where all neccessary items will be stored.\nYou will be also prompt to choose which context menu items you wish to apply.\n1. Run test in Sandbox\n1. Pack with IntunewinUtil\n1. Both\n\n# Updating\n\n```powershell\nUpdate-Module -Name Intune-App-Sandbox\n```\nRun `Update-SandboxShell`\n\n# How to use\nPacking script and all neccessary executables is as simple as creating parent folder which is named exacly the same as `.ps1` script inside.\u003cbr\u003e\nThen right-click on folder and pick `Pack with IntunewinUtil`.\n\u003cbr\u003e\u003cbr\u003e\n![Pack](packintuneutil.gif)\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\nTo test your package just right-click on `.intunewin` file and choose\n`Run test in Sandbox`\n![Test](testsandbox.gif)\n\n# New feature - Run test with detection\nWith version 1.3.0 I've introduced new feature that allows to test your installation and test your custom detection script.\nTo do that you need to have script file in package location and its name must follow the same principal as installation script name but with `_Detection` and the end:\n\n**Install-ProgramScriptTemplate_Detection.ps1**\n\nDetection script must end with exit code **1** if app is not found and **0** if found.\nTo use this new feature click on orange/gold item in cotext menu - you will know which one 😉\n\n# Technical details\n## Template script\nAt `SandboxEnvironment` location you will find my template installation script.\nIt's creation helped me to reduce time spent on every installation package.\nNow most of the times it comes down to changing Parameters region.\n\n```powershell\n# Parameters\n$FileName = \"VSCodeSetup-x64-1.50.0.exe\"\n$Tag = 'VSCode'\n$OperatingFolder = 'C:\\Program Files (x86)\\Microsoft\\Temp'\n$ArgumentListInstallation = '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /NOCANCEL /SP- /LOG=\"{0}\\{1}Install.log\" /MERGETASKS=!runcode' -f $OperatingFolder, $Tag\n$InstallFailCode = 1707\n$InstallSuccessCode = 1641\n\n# Log\n$LogFile = \"$OperatingFolder\\IntuneSoftwareInstall.log\"\n$LogFileError = \"$OperatingFolder\\IntuneSoftwareInstallError.log\"\n\n#Info\n. $PSScriptRoot\\Write-FileLog.ps1\n\n#Custom exit\nfunction Exit-WithCode {\n\tparam\n\t(\n\t\t$exitcode\n\t)\n\n\t$host.SetShouldExit($exitcode)\n}\n#######################################################################\n#Check for folder\nIf (Test-Path -Path $OperatingFolder -PathType Container) {\n\tWrite-FileLog -FunctionStart -LogFile $LogFile\n} Else {\n\tNew-Item -Path $OperatingFolder -ItemType Directory\n\tWrite-FileLog -Message \"$OperatingFolder created\" -LogFile $LogFile\n}\n\n#Install\nWrite-FileLog -FunctionStart -LogFile $LogFile\nWrite-FileLog -Message \"Installation with arguments: $ArgumentListInstallation\" -LogFile $LogFile\nTry {\n\t$Process = Start-Process $PSScriptRoot\\$FileName -ArgumentList $ArgumentListInstallation -NoNewWindow -PassThru -Wait -ErrorAction Stop\n\tWrite-FileLog -Message \"Installation exit code: $($Process.ExitCode)\" -LogFile $LogFile\n\n\tIf ($Process.ExitCode -ne 0) {\n\t\tWrite-FileLog -Type Error -Message \"Installation failed. Please check $OperatingFolder\\${Tag}Install.log\" -LogFileError $LogFileError\n\t\tExit-WithCode -exitcode $InstallFailCode\n\t} else {\n\t\tWrite-FileLog -Message \"Installation $FileName SUCCESS\" -LogFile $LogFile\n\t\tExit-WithCode -exitcode $InstallSuccessCode\n\t}\n} Catch {\n\tWrite-FileLog -Type Error -Message \"Script ERROR\" -LogFileError $LogFileError\n\t$_ | Out-File -FilePath $LogFileError -Append -Encoding ASCII\n\tWrite-FileLog -Type Warn -Message \"Script TERMINATION\" -LogFileError $LogFileError\n\tWrite-FileLog -Type Warn -Message \"Exitcode $InstallFailCode\" -LogFileError $LogFileError\n\tExit-WithCode -exitcode $InstallFailCode\n}\n```\n\n## Host part\nWindows Sandbox file is created at location `C:\\SandboxEnvironment`.\nThis file contains configuration details about Sandbox.\n\nEg.\n```xml\n\u003cConfiguration\u003e\n\u003cVGpu\u003eEnable\u003c/VGpu\u003e\n\u003cNetworking\u003eEnable\u003c/Networking\u003e\n\u003cMappedFolders\u003e\n\u003cMappedFolder\u003e\n\u003cHostFolder\u003eC:\\Intune\\Client apps - Apps\\Restart-Device\u003c/HostFolder\u003e\n\u003cReadOnly\u003etrue\u003c/ReadOnly\u003e\n\u003c/MappedFolder\u003e\n\u003cMappedFolder\u003e\n\u003cHostFolder\u003eC:\\SandboxEnvironment\\bin\u003c/HostFolder\u003e\n\u003cReadOnly\u003etrue\u003c/ReadOnly\u003e\n\u003c/MappedFolder\u003e\n\u003c/MappedFolders\u003e\n\u003cLogonCommand\u003e\n\u003cCommand\u003epowershell.exe -WindowStyle Hidden -noprofile -executionpolicy bypass -Command C:\\Users\\WDAGUtilityAccount\\Desktop\\bin\\Restart-Device_LogonCommand.ps1\u003c/Command\u003e\n\u003c/LogonCommand\u003e\n\u003c/Configuration\u003e\n```\n\nCore eleement is Logon Command.\nThis script is run after Sandbox environment starts.\n\n## Sandbox part\nEg. you have Restart-Device.intune, then logon command will be as below\n```powershell\nIf (!(Test-Path -Path C:\\Temp -PathType Container))\n{\n\tNew-Item -Path C:\\Temp -ItemType Directory\n}\nCopy-Item -Path \"C:\\Users\\WDAGUtilityAccount\\Desktop\\Restart-Device\\Restart-Device.intunewin\" -Destination C:\\Temp\n$Decoder = Start-Process -FilePath C:\\Users\\WDAGUtilityAccount\\Desktop\\bin\\IntuneWinAppUtilDecoder.exe -ArgumentList \"C:\\Temp\\Restart-Device.intunewin /s\" -NoNewWindow -PassThru -Wait\n\nRename-Item -Path \"C:\\Temp\\Restart-Device.intunewin.decoded\" -NewName 'Restart-Device.zip' -Force;\nExpand-Archive -Path \"C:\\Temp\\Restart-Device.zip\" -Destination C:\\Temp -Force;\nRemove-Item -Path \"C:\\Temp\\Restart-Device.zip\" -Force;\n\n# register script as scheduled task\n$Trigger = New-ScheduledTaskTrigger -Once -At $(Get-Date).AddMinutes(1)\n$User = \"SYSTEM\"\n$Action = New-ScheduledTaskAction -Execute \"powershell.exe\" -Argument '-ex bypass \"powershell {\u0026 C:\\Temp\\Restart-Device.ps1};New-Item C:\\Temp\\$Lastexitcode.code -force\"'\n$Settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit \"01:00\" -AllowStartIfOnBatteries\nRegister-ScheduledTask -TaskName \"Install App\" -Trigger $Trigger -User $User -Action $Action -Settings $Settings -Force\n```\nThis package is decoded within Sandbox environment.\nDecoded contents are then expanded and to path `C:\\Temp`.\nThen Scheduled Task is created which will start `Powershell` within `Powershell` to run script contents.\nThanks to nesting `Powershell` runspaces after script ends, `$LASTEXITCODE` is saved in form of file at script location.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUniverseCitiz3n%2FIntune-App-Sandbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FUniverseCitiz3n%2FIntune-App-Sandbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUniverseCitiz3n%2FIntune-App-Sandbox/lists"}