Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [CmdletBinding()]
- Param(
- [Parameter(Mandatory=$true)]
- [ArgumentCompleter({
- param($cmd, $param, $wordToComplete)
- [array]$ItemList = (Get-ChildItem -Path $global:IntunePackages -Directory | Where-Object {$_.Name -inotmatch "^\d{1,2}-"}).Name
- $ItemList -ilike "$wordToComplete*"
- })]
- [ValidateScript({
- if (Test-Path -Path "$global:IntunePackages\$_" -PathType Container) {
- $_ -inotmatch "^\d{1,2}-"
- }
- else {
- $false
- }
- })]
- [String]$PackageName,
- [Switch]$Force
- )
- [String]$Source = "$global:IntunePackages\$PackageName"
- [String]$Script = ''
- [String]$Output = $global:IntunePackagePath
- [String[]]$Params = @()
- if ((Get-ChildItem -Path "${Source}\*" -Include "Deploy-Application.*","ServiceUI.exe" | Measure-Object).Count -eq 4) {
- $Script = Get-ChildItem -Path "${Source}\*" -Filter "*.ps1" -Exclude "Deploy-Application.ps1" | Select-Object -ExpandProperty 'Name' -First 1
- if (!($Script)) {
- Write-Error "'$Source' is missing critical files.`nMake sure all necessary files are in the project folder."
- Remove-Variable PackagePath,Force,Source,Script,Output,Params
- return
- }
- $Params = @('-c',"$Source",'-s',"$Script",'-o',"$Output")
- if ($Force) {
- $Params += "-q"
- }
- & $global:IntunePackages\IntuneWinAppUtil.exe $Params
- }
- else {
- Write-Error "'$Source' is missing critical files.`nMake sure all necessary files are in the project folder."
- }
- Remove-Variable PackageName,Force,Source,Script,Output,Params -Force
Add Comment
Please, Sign In to add comment