Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Experts,
I am using Qlik Cli in powershell to assign custom property values to users. The code seem to work fine, but I see numbers with the value that gets assigned to the custom property.
Here is the snapshot. Does it mean the same value is getting assigned multiple times (like 2787 and 6706) times?
here is the code if anyone wants to take a look -
$CSVUsers = Get-Content D:\custom_files\updatecustomproperties\QS_User_App_Access.csv|ConvertFrom-Csv
Connect-Qlik -TrustAllCerts
#region update Missing Custom Property Values
##Update the Custom Property if a value is missing.
$UCP = $CSVUsers.Customproperty|Select -Unique
$UCPNames = $UCP|%{$($_ -split "=")[0]}|select -Unique
foreach($UCPName in $UCPNames){
$Changes = $false
$Values = $UCP|?{$_.StartsWith("$($UCPName)=")}|%{$($_ -split "=")[1]}
$QSCustomProperty = Get-QlikCustomProperty -filter "Name eq '$($UCPName)'" -full
$Values|%{
if (!($_ -in $QSCustomProperty.choiceValues)){
$QSCustomProperty.choiceValues += $_
$Changes=$true
}
}
if ($Changes -eq $true){
$QSCustomProperty = Update-QlikCustomProperty -id $QSCustomProperty.id -choiceValues $QSCustomProperty.choiceValues
}
}
#endregion update Missing Custom Property Values
#region update User object
foreach ($CSVUser in $CSVUsers){
$QSUser = Get-QlikUser -filter "UserID eq '$($CSVUser.UserId)'" -full
if ($null -eq $QSUser){Write-Warning "User with ID $($CSVUser.UserId) Doest Not Exist"}else{
[string[]]$customProperties = ""
<# #Include the next line to maintain existing properties, exclude it to only include value from CSV.#>
[string[]]$customProperties = $($QSUser.customProperties|%{"$($_.definition.Name)=$($_.value)"})
$customProperties += $CSVUser.Customproperty
$QSUser | Update-QlikUser -customProperties $customProperties
}
}
#endregion update User object
thanks