I am trying to set a task sequence variable using a PowerShell form.
Setting the task sequence variable and controlling the ProgressUI was straightforward but when it comes to the form itself, it just does not appear.
Reducing my script to the minimum, these four lines of code open a blank form when run from PowerShell, but running the same script from an MDT task sequence action "Run PowerShell Script" does not display the form and the task sequence is blocked at that point. My guess is that the form is open but just not visible.
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$form = New-Object System.Windows.Forms.Form
$form.Add_Shown({$form.Activate()})
$dialogResult = $form.ShowDialog()
Accidentally I found that if I added the following line anywhere before the ShowDialog() call the form is displayed correctly (as is an empty GridView)
"" | Out-GridView
Looking at this example online, http://www.scconfigmgr.com/2015/07/17/windows-forms-powershell-gui-template/, I can't see a material difference and setting the extra $form properties doesn't help.
Can anyone offer any suggestion on this?
I'm using MDT 6.3.8443.1000