Set-ADClaimType: adding suggestions

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 7 years and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
DeKade
Posts: 18
Last visit: Fri Mar 04, 2022 2:16 am

Set-ADClaimType: adding suggestions

Post by DeKade »

I want to programmatically add Suggested Values for an ADClaimType

I can only find this command: Set-ADClaimType https://technet.microsoft.com/en-us/lib ... .630).aspx
It seems it only takes New-Object Microsoft.ActiveDirectory.Management.ADSuggestedValueEntry as argument for -SuggestedValues
Each entry seperated by a comma.

Ofcourse if I do this, I lose the current values in that collection.
So my train of thought was to load those in first, and Re-add them with the Set Cmdlet, together with the new value.

I have my Current Suggested values in an Microsoft.ActiveDirectory.Management.ADPropertyValueCollection $(Get-ADClaimType -identity "name").SuggestedValues

But how do I get those Values on the command Line seperated by a comma?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Set-ADClaimType: adding suggestions

Post by jvierra »

The command line takes an array - collection. Just use it.
User avatar
DeKade
Posts: 18
Last visit: Fri Mar 04, 2022 2:16 am

Re: Set-ADClaimType: adding suggestions

Post by DeKade »

I kinda solved this by casting the SuggestedValues I got from Get-ADClaimType -identity "name").SuggestedValues
from a ADPropertyValueCollection to a regular Object[] ..

Set-ADClaimType -SuggestedValues takes this regular Object[] as argument as mentioned above


Kinda strange there is no "add" functionality for that Collection?
I'm new to powershell: I've seen some @{add= syntax, but that doesn't seem to work with this.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Set-ADClaimType: adding suggestions

Post by jvierra »

The purpose of defining the parameter as [object[]] is because it will automatically do the cast for you. That is how parameters work in most languages.
This topic is 7 years and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked