I have a requirement to show list of options as checklist to user for selection. If followed In Powershell how to enable/show options like Select All | DeSelect All for Multilist field type , it have static data for checklist then its working fine but when i am having an object whoes value evaluated at runtime then its not working. e.g.

$scriptitems =  get-childitem '/sitecore/system/Modules/PowerShell/Script Library' -recurse | where{$_.templateid -eq '{DD22F1B3-BD87-4DB2-9E7D-F7A496888D43}' } |foreach-object{



Now i want to show this list as input to user, if i use below code:

$dialogParams = @{
    Title = "Dialog title"
    Description = "Description under title"
    OkButtonName = "Execute"
    CancelButtonName = "Close"
    ShowHints = $true
    Parameters = @(
            Name = "checkListSelector"
            Title = "Checklist Selector"
            Editor = "checklist"
            Options = $scriptlist
            Tooltip = "Select one or more options"

But getting error in logs: enter image description here

$dialogResult = Read-Variable @dialogParams

Although i tried to change (Options = $scriptlist) with new variable but that also didn't work.

Please let me know if i am missing anything.

1 Answer 1


You're missing ".ToString()" after .guid.


And you should switch the order most probably, like that:

$scriptlist.add($currentscript.DisplayName, $currentscript.id.guid.ToString())    
  • Thanks, able to see result now, but still have two issue 1. Currently checklist displays itemid but If i change the order as you suggested, i got error "Item has already been added. Key in dictionary" due to duplicate key name(Due to it i had changed the order but then on UI it shows itemlist). 2. $scriptlist (or any new variable) not persist selected checkbox list, in other words we need to get list of option selected by user. $checkListOptions = $scriptlist.clone() ........ $dialogResult = Read-Variable @dialogParams
    – Rinku Jain
    Commented Apr 5, 2022 at 8:37
  • You should limit posts here to a single question. Create a new one with your further questions.
    – Marek Musielak
    Commented Apr 5, 2022 at 9:09
  • sure, accepted the answer
    – Rinku Jain
    Commented Apr 5, 2022 at 12:45
  • 1
    I got fix for my other two issue as well, 1. i was referring wrong variable to access selected checklist, it should be checkListSelector 2. I have added relative path to keys so that it will be distinct. Now will work on my rest of the script... :)
    – Rinku Jain
    Commented Apr 6, 2022 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.