0

I am writing a script which deletes users who have not logged in since a user-provided date.

I want to do the following:

  1. Get date from user. (no problem here)
  2. Get a list of users. (no problem here)
  3. Present the user with a ListView of the potentially affected users. (no problem here)
  4. Wait for the modal window to be closed before proceeding (this is where I get stuck)
  5. Do some other stuff...

Steps 1-3 work fine, but when the modal window pops up, all of the code after gets executed immediately with the model window still open.

I thought Wait-ScriptSession might be my answer, but it is not doing the trick. Here's what I have right now (psuedo-code)

#gather users, etc
Start-ScriptSession -ScriptBlock {$listOfRemovedUsers | Show-ListView @outputProps -Property $columns} -Id "Removable Users Modal" -Interactive
Wait-ScriptSession -Id "Removable Users Modal" -Timeout 30
#do some more stuff
Michael
  • 79
  • 6
  • I am not sure this will help but once I asked similar and was told https://stackoverflow.com/questions/69050623/wait-process-does-not-always-work-with-start-process – dcaz Dec 10 '21 at 16:49
  • and https://stackoverflow.com/questions/68727495/start-process-invoke-command-or – dcaz Dec 10 '21 at 16:52

2 Answers2

0

Instead of using a Wait-ScriptSession use a Confirmation Dialogue as follow just after you run the Show-ListView

 $listOfRemovedUsers | Show-ListView @outputProps -Property $columns
 Show-Confirm -Title "Do you want to proceed"
    

And you get a popup that will ask you if you want to proceed. on the meantime the script execution will be blocked until you click OK or Cancel enter image description here

BETOMBO
  • 174
  • 5
0

I faced a similar situation. The only solution I found was to use the "-modal" parameter: https://doc.sitecorepowershell.com/appendix/common/show-listview#modal-less-than-switchparameter-greater-than

Something like this:

$listOfRemovedUsers | Show-ListView -Modal
$response = Show-Confirm -Title "Do you want to proceed?"