Package your PowerShell script as a Win32 app for more advanced deployment options, including custom detection rules and dependencies.
First, download the Microsoft Win32 Content Prep Tool from the official Microsoft repository. Create a source folder structure:
# Create Win32 app structure
New-Item -Path "C:\IntuneScripts\Win32Source" -ItemType Directory -Force
New-Item -Path "C:\IntuneScripts\Win32Output" -ItemType Directory -Force
# Copy script to source folder
Copy-Item "Create-AppShortcuts.ps1" "C:\IntuneScripts\Win32Source\"
Create an installation wrapper script in the Win32Source folder:
# Install-Shortcuts.ps1 (wrapper script)
$scriptPath = Join-Path $PSScriptRoot "Create-AppShortcuts.ps1"
if (Test-Path $scriptPath) {
try {
& $scriptPath
Write-Output "Shortcuts installed successfully"
exit 0
} catch {
Write-Error "Installation failed: $($_.Exception.Message)"
exit 1
}
} else {
Write-Error "Script file not found: $scriptPath"
exit 1
}
Package the app using IntuneWinAppUtil:
IntuneWinAppUtil.exe -c "C:\IntuneScripts\Win32Source" -s "Install-Shortcuts.ps1" -o "C:\IntuneScripts\Win32Output"
In Intune, go to Apps > Windows > Add > Win32 app and upload the generated .intunewin file.
Configure the app settings:
Install command: powershell.exe -ExecutionPolicy Bypass -File "Install-Shortcuts.ps1"
Uninstall command: powershell.exe -Command "Remove-Item '$env:Public\Desktop\Calculator.lnk' -Force; Remove-Item '$env:Public\Desktop\Notepad.lnk' -Force"
Install behavior: System
Device restart behavior: No specific action
Create a detection rule using file existence:
Rule type: File
Path: C:\Users\Public\Desktop
File or folder: Calculator.lnk
Detection method: File or folder exists
Verification: Deploy to a test group and monitor installation status in Apps > Monitor > App install status.