public/Get-AppVentiXPublishingTask.ps1
<#
.SYNOPSIS Retrieves the publishing tasks from the AppVentiX configuration share. .DESCRIPTION The Get-AppVentiXPublishingTask function retrieves the publishing tasks from the specified AppVentiX configuration share. It checks if AppVentiX is licensed and if the publishing tasks file exists. If successful, it returns the publishing tasks as an output. .PARAMETER UserPublishingTasks Retrieves the user publishing tasks. This is the default if no parameter is specified. .PARAMETER GlobalPublishingTasks Retrieves the global publishing tasks. .PARAMETER All Retrieves both the global and user publishing tasks. .PARAMETER ConfigShare Specifies the path to the AppVentiX configuration share. You can ommit this parameter if Set-AppVentiXConfigShare has been called. .EXAMPLE Get-AppVentiXPublishingTask Retrieves the (User) publishing tasks from the default AppVentiX configuration share. .EXAMPLE Get-AppVentiXPublishingTask -ConfigShare "\\server\share" Retrieves the (User) publishing tasks from the specified AppVentiX configuration share "\\server\share". .EXAMPLE Get-AppVentiXPublishingTask -All Retrieves both the global and user publishing tasks from the default AppVentiX configuration share. .NOTES Function : Get-AppVentiXPublishingTask Author : John Billekens Copyright: Copyright (c) AppVentiX Version : 1.0 #> function Get-AppVentiXPublishingTask { [CmdletBinding(DefaultParameterSetName = 'User')] param ( [Alias('Global')] [Parameter(ParameterSetName = 'Global', Mandatory)] [Switch]$GlobalPublishingTasks, [Alias('User')] [Parameter(ParameterSetName = 'User')] [Switch]$UserPublishingTasks, [Parameter(ParameterSetName = 'All', Mandatory)] [Switch]$All, [Alias('Config', 'Share', 'AppVentixConfigShare')] [Parameter(ParameterSetName = 'All')] [Parameter(ParameterSetName = 'Global')] [Parameter(ParameterSetName = 'User')] [ValidateNotNullOrEmpty()] [String]$ConfigShare = $Script:AppVentix.ConfigShare ) if (Test-AppVentiXIsLicensed -ConfigShare $ConfigShare) { $publishingTasksFullname = Join-Path -Path $ConfigShare -ChildPath $Script:AppVentiX.PublishingTasksFilename if (Test-Path -Path $publishingTasksFullname) { [xml]$publishingTasksXml = Get-Content -Path $publishingTasksFullname $publishingTasks = ConvertFrom-Xml -InputObject $publishingTasksXml.Root $global = @($publishingTasks.GlobalPublishingTasks.Packages.Task) $user = @($publishingTasks.UserPublishingTasks.Packages.Task) if ($GlobalPublishingTasks) { Write-Verbose "Retrieving global publishing tasks (-Global $GlobalPublishingTasks)" $output = $global } elseif ($PSCmdlet.ParameterSetName -eq 'User' -or $UserPublishingTasks) { Write-Verbose "Retrieving user publishing tasks (-User $UserPublishingTasks)" $output = $user } else { Write-Verbose "Retrieving all publishing tasks (-All $All)" $output = "" | Select-Object -Property GlobalPublishingTasks, UserPublishingTasks $output.GlobalPublishingTasks = $global $output.UserPublishingTasks = $user } return $output } else { Write-Warning "`"$($Script:PublishingTasksFilename)`" file not found!" } } else { Write-Warning 'AppVentiX is not licensed!' } } |