Update-QlikNode.ps1
function Update-QlikNode { <# .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-QlikNode '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, [ValidateSet("Production", "Development", "Both")] [string]$nodePurpose, [string[]]$customProperties, [string[]]$tags, [switch]$engineEnabled, [switch]$proxyEnabled, [switch]$schedulerEnabled, [switch]$printingEnabled ) begin { } process { $node = Get-QlikNode $id If( $name ) { $node.name = $name } If( $nodePurpose ) { switch($nodePurpose) { Production { $node.nodePurpose = 0 } Development { $node.nodePurpose = 1 } Both { $node.nodePurpose = 2 } } } If( $customProperties ) { $prop = @( $customProperties | foreach { $val = $_ -Split "=" $p = Get-QlikCustomProperty -filter "name eq '$($val[0])'" @{ value = ($p.choiceValues -eq $val[1])[0] definition = $p } } ) $node.customProperties = $prop } If( $tags ) { $node.tags = $tags } If( $psBoundParameters.ContainsKey("engineEnabled") ) { $node.engineEnabled = $engineEnabled.IsPresent } If( $psBoundParameters.ContainsKey("proxyEnabled") ) { $node.proxyEnabled = $proxyEnabled.IsPresent } If( $psBoundParameters.ContainsKey("schedulerEnabled") ) { $node.schedulerEnabled = $schedulerEnabled.IsPresent } If( $psBoundParameters.ContainsKey("printingEnabled") ) { $node.printingEnabled = $printingEnabled.IsPresent } $json = $node | ConvertTo-Json -Compress -Depth 10 return Invoke-QlikPut "/qrs/servernodeconfiguration/$id" $json } end { } } if ($loadingModule) { Export-ModuleMember -Function 'Update-QlikNode' } |