Functions/Start-IntuneWin32Packaging.ps1
function Start-IntuneWin32Packaging { [CmdletBinding()] param ( # Specifies a path to one or more locations. [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [Alias("PSPath")] [ValidateNotNullOrEmpty()] [string] $AppFolder = ".", # [Parameter(Mandatory)] [path] $AppFolder, [Parameter()] [string] $SetupFile = "install.cmd", [Parameter()] [string] $IntuneWinAppUtilLocation = "C:\Temp\Intune\Microsoft-Win32-Content-Prep-Tool-master\IntuneWinAppUtil.exe" ) if (Test-Path $IntuneWinAppUtilLocation) { } elseif (Test-Path "$([Environment]::GetFolderPath("UserProfile"))\git\Microsoft-Win32-Content-Prep-Tool\IntuneWinAppUtil.exe") { $IntuneWinAppUtilLocation = "$([Environment]::GetFolderPath("UserProfile"))\git\Microsoft-Win32-Content-Prep-Tool\IntuneWinAppUtil.exe" } else { throw "File not found: $IntuneWinAppUtilLocation" } if (Resolve-Path $SetupFile) { $SetupFileFullPath = Resolve-Path $SetupFile $SetupFileName = (Get-Item $SetupFileFullPath).Name } else { $SetupFileName = $SetupFile } if (!(Test-Path $AppFolder)) { throw "Folder not found: $AppFolder" } # $SourceFolder = Join-Path $AppFolder -ChildPath "source" # $SourceFolder = $AppFolder $SourceFolder = (Resolve-Path $AppFolder).Path $SourceFolderPathLength = $SourceFolder.get_Length() $SourceFolderLastChar = $SourceFolder.Substring($SourceFolderPathLength - 1) # $SourceFolderLastChar if ($SourceFolderLastChar -eq "\") { $SourceFolder = $SourceFolder.Substring(0, $SourceFolderPathLength - 1) } # $OutputFolder = Join-Path $AppFolder -ChildPath "output" $OutputFolder = $SourceFolder $SourceFolder = $SourceFolder + "\source" # if (!(Test-Path $SourceFolder)) { # throw "Folder not found: $SourceFolder" # } # if (!(Test-Path $OutputFolder)) { # New-Item $OutputFolder -ItemType Directory | Out-Null # } # $SetupFileFullPath = Join-Path $SourceFolder -ChildPath $SetupFile # if (!(Test-Path $SetupFileFullPath)) { # throw "File not found: $SetupFileFullPath" # } Get-ChildItem $OutputFolder -File -Filter "*.intunewin" | Remove-Item -Force # Write-Output '$IntuneWinAppUtilLocation -ArgumentList '-c "$($SourceFolder)" -s "$($SetupFile)" -o "$($OutputFolder)"' Start-Process $IntuneWinAppUtilLocation -ArgumentList "-c `"$($SourceFolder)`" -s `"$($SetupFileName)`" -o `"$($OutputFolder)`"" -Wait -NoNewWindow -Verbose } |