Update-QlikApp.ps1

function Update-QlikApp {
    <#
    .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
    Update-QlikApp 'abc'
 
    Description of the example.
 
    #>


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

    [string]$name,
    [string]$description,
    [string[]]$customProperties,
    [string[]]$tags
    )

    begin {
    }

    process {
    $app = Get-QlikApp $id -raw
    If( $name ) { $app.name = $name }
    If( $description ) { $app.description = $description }
    If( $customProperties ) {
      $prop = @(
        $customProperties | foreach {
          $val = $_ -Split "="
          $p = Get-QlikCustomProperty -filter "name eq '$($val[0])'" -raw
          @{
            value = ($p.choiceValues -eq $val[1])[0]
            definition = $p
          }
        }
      )
      $app.customProperties = $prop
    }

    If( $tags ) {
      $prop = @(
        $tags | foreach {
          $p = Get-QlikTag -filter "name eq '$_'"
          @{
            id = $p.id
          }
        }
      )
      $app.tags = $prop
    }

    $json = $app | ConvertTo-Json -Compress -Depth 10
    return Invoke-QlikPut "/qrs/app/$id" $json
  }

    end {
    }
}

if ($loadingModule) {
    Export-ModuleMember -Function 'Update-QlikApp'
}