# Show Form During Logon Script

**URL:** <https://forums.powershell.org/t/show-form-during-logon-script/10995>\
**Category:** PowerShell Help\
**Created:** [July 19, 2018, 10:02am UTC](https://forums.powershell.org/t/show-form-during-logon-script/10995 "2018-07-19T10:02:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![networkinfopinaldps](https://avatars.discourse-cdn.com/v4/letter/n/67e7ee/32.png) [@networkinfopinaldps](https://forums.powershell.org/u/networkinfopinaldps)\
**Post date:** [July 19, 2018, 10:02am UTC](https://forums.powershell.org/t/show-form-during-logon-script/10995/1 "2018-07-19T10:02:55Z")

</div>

I have a powershell logon script via GPO. I would like to show a form when the script runs. Works great from the ISE but doesn’t do anything during the logon script.

Thanks for any help!

```
Add-Type -AssemblyName System.Windows.Forms

$form = New-Object System.Windows.Forms.Form
$form.Text = "" 
$form.Size = New-Object System.Drawing.Size(400, 800) #width, height
$form.Font = New-Object System.Drawing.Font("Comic Sans MS",16,[System.Drawing.FontStyle]::Regular)
$form.MinimizeBox = $False
$form.MaximizeBox = $False
$form.WindowState = "Normal" #Maximized, Minimized, Normal
$form.SizeGripStyle = "Hide" #Auto, Hide, Show
$form.ShowInTaskbar = $False
$form.Opacity = 1.0 #1.0 is fully opaque; 0.0 is invisible
$form.StartPosition = "CenterScreen" # CenterScreen, Manual, WindowsDefaultLocation, WindowsDefaultBounds, CenterParent

$label1 = New-Object System.Windows.Forms.label
$label1.BackColor = "Transparent"
$label1.BorderStyle = "None"
$label1.Location = New-Object System.Drawing.Point(1, 375) #left, top
$label1.Text = "Test Line 1"
$label1.TextAlign = "MiddleCenter"
$label1.Width = 800
$form.Controls.Add($label1)

$form.ShowDialog()

```

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [July 19, 2018, 1:41pm UTC](https://forums.powershell.org/t/show-form-during-logon-script/10995/2 "2018-07-19T13:41:31Z")

</div>

Yeah, the ISE is not a good “testbed.” But there’s a further complexity with logon scripts where PowerShell doesn’t get front-most execution priority. There’s not actually much you can do about that, as it’s not PowerShell’s fault, but rather the way GPs are processed and given system access.

Is the goal here to collect information, or just display a message?

---

<div class="post-metadata">

**Author:** ![postanote](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@postanote](https://forums.powershell.org/u/postanote)\
**Post date:** [July 19, 2018, 8:37pm UTC](https://forums.powershell.org/t/show-form-during-logon-script/10995/3 "2018-07-19T20:37:45Z")

</div>

Ditto on the GPO preference and the .ps1 priority.  
Your post runs as expected in the ISE/ConsoleHost/VSCode/PSStudio, and even from a scheduled task.  
So, something else is the catch22.

---

<div class="post-metadata">

**Author:** ![networkinfopinaldps](https://avatars.discourse-cdn.com/v4/letter/n/67e7ee/32.png) [@networkinfopinaldps](https://forums.powershell.org/u/networkinfopinaldps)\
**Post date:** [July 20, 2018, 7:45am UTC](https://forums.powershell.org/t/show-form-during-logon-script/10995/4 "2018-07-20T07:45:28Z")

</div>

Thanks for the replies. In this case the solution was simple…I just added $form.topmost to the code.

Thanks again!

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:34pm UTC](https://forums.powershell.org/t/show-form-during-logon-script/10995/5 "2024-05-16T20:34:42Z")

</div>


