New-QlikTask.ps1

function New-QlikTask {
    <#
    .SYNOPSIS
    This function ...
 
    .DESCRIPTION
    A bit more description
 
    .PARAMETER FromPipeline
    Shows how to process input from the pipeline, remaining parameters or by named parameter.
 
    .EXAMPLE
    New-QlikTask 'abc'
 
    Description of the example.
 
    #>


    <# Enable -Confirm and -WhatIf. #>
    [CmdletBinding(SupportsShouldProcess = $true)]
    param(
       [parameter(Mandatory=$true,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,Position=0)]
    [alias("id")]
    [string]$appId,
    [parameter(Mandatory=$true,Position=1)]
    [string]$name,
    [string[]]$tags
    )

    begin {
    }

    process {
    If( $tags ) {
      $tagArray = @(
        $tags | foreach {
          $p = Get-QlikTag -filter "name eq '$_'" -raw
          @{
            id = $p.id
          }
        }
      )
    } else {
      $tagArray = @();
    }

    $task = @{
      task = @{
        name = $name;
        taskType = 0;
        enabled = $true;
        taskSessionTimeout = 1440;
        maxRetries = 0;
        tags = $tagArray;
        app = @{
          id = $appId
        };
        isManuallyTriggered = $false;
        customProperties = @()
      };
    }

    $json = $task | ConvertTo-Json -Compress -Depth 10

    return Invoke-QlikPost '/qrs/reloadtask/create' $json
  }

    end {
    }
}

if ($loadingModule) {
    Export-ModuleMember -Function 'New-QlikTask'
}