resources/userdirectory.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
function Get-QlikUserDirectory { [CmdletBinding()] param ( [parameter(Position = 0)] [string]$id, [string]$filter, [switch]$full, [switch]$raw ) PROCESS { $path = "/qrs/userdirectory" If ( $id ) { $path += "/$id" } If ( $full ) { $path += "/full" } If ( $raw ) { $rawOutput = $true } return Invoke-QlikGet $path $filter } } function New-QlikUserDirectory { [CmdletBinding()] param ( [parameter(Mandatory = $false, Position = 0)] [string]$name, [parameter(Mandatory = $false, Position = 1)] [string]$userDirectoryName, [string]$type, [string]$configured = $false, [string]$syncOnlyLoggedInUsers = $true, [string]$syncStatus = 0, [string]$configuredError = "", [string]$operationalError = "", [System.Object[]]$settings = @(), [string[]]$tags ) PROCESS { $ud = @{ name = $name; userDirectoryName = $userDirectoryName; configured = $configured; operational = $false; type = $type; syncOnlyLoggedInUsers = $syncOnlyLoggedInUsers; syncStatus = $syncStatus; configuredError = $configuredError; operationalError = $operationalError; settings = $settings } if ($PSBoundParameters.ContainsKey("tags")) { $ud.tags = @(GetTags $tags) } $json = $ud | ConvertTo-Json -Compress -Depth 10 return Invoke-QlikPost "/qrs/UserDirectory" $json } } function Remove-QlikUserDirectory { [CmdletBinding()] param ( [parameter(Position = 0, ValueFromPipelinebyPropertyName = $true)] [string]$id ) PROCESS { return Invoke-QlikDelete "/qrs/userdirectory/$id" } } function Sync-QlikUserDirectory { [CmdletBinding()] param ( [System.Guid[]]$guid = @() ) PROCESS { $json = ConvertTo-Json -Compress -Depth 10 $guid return Invoke-QlikPost "/qrs/userdirectoryconnector/syncuserdirectories" $json } } function Update-QlikUserDirectory { [CmdletBinding()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "password", Justification = "Deprecation warning")] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingUserNameAndPassWordParams", "", Justification = "Deprecation warning")] param ( [parameter(Mandatory = $true, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True, Position = 0)] [string]$id, [string]$name, [string]$path, [string]$username, [string]$password, [PSCredential]$Credential, [string]$ldapFilter, [int]$timeout, [Int]$pageSize, [object[]]$tags ) PROCESS { if ( $username -Or $password ) { Write-Warning "Use of username/password parameters is deprecated, please use Credential instead." } if ( $Credential ) { $username = $Credential.Username $password = $Credential.GetNetworkCredential().Password } $ud = Get-QlikUserDirectory -id $id -raw if ($name) { $ud.name = $name } if ($path) { ($ud.settings | Where-Object name -EQ path).value = $path } if ($username) { ($ud.settings | Where-Object name -EQ 'User name').value = $username } if ($password) { ($ud.settings | Where-Object name -EQ password).value = $password } if ($ldapFilter) { ($ud.settings | Where-Object name -EQ 'LDAP Filter').value = $ldapFilter } if ($timeout) { ($ud.settings | Where-Object name -EQ 'Synchronization timeout in seconds').value = $timeout } if ($pageSize) { ($ud.settings | Where-Object name -EQ 'Page size').value = $pageSize } if ($PSBoundParameters.ContainsKey("tags")) { $ud.tags = @(GetTags $tags $ud.tags) } $json = $ud | ConvertTo-Json -Compress -Depth 10 return Invoke-QlikPut -path "/qrs/userdirectory/$id" -body $json } } |