Popup message to users by PowerShell

Hello guys,

I have made a PowerShell script for you, this PS script helps you to inform users in urgent or updates, cases.

You can deploy this PS1 file by SCCM, GPO, any other distribution tool.

Add-Type -AssemblyName system.windows.Forms
$user = $env:USERNAME
$Form = New-Object system.windows.forms.form
$Form.Text = "Good Morning,$user" 
$Font = New-Object System.Drawing.Font("Tahoma",14,[System.Drawing.FontStyle]::Regular)
$Form.Size = New-Object System.Drawing.Size(500,500) 
$Form.Font = $Font
$Image = [system.drawing.image]::FromFile("$($Env:Public)\Pictures\PelegIT1.jpg")
#Make sure the pic is located on users computers
$Form.BackgroundImage = $Image
$Form.BackgroundImageLayout = "None"
$Icon = [system.drawing.icon]::ExtractAssociatedIcon($PSHOME + "\powershell.exe")
$Form.Icon = $Icon
$Label = New-Object System.Windows.Forms.Label
$Form.StartPosition = "CenterScreen"
$Label.Text = "Hi $user","`n","`n`rWelcome to my IT Blog ","","`n `nThank you for visiting my IT blog,Meir Peleg"
$Label.AutoSize = $true 
$Label.Location = New-Object System.Drawing.Size(95,50) 
$Form.MinimizeBox = $False
$Form.MaximizeBox = $False
$ThanksButton = New-Object System.Windows.Forms.Button
$ThanksButton.Location = New-Object System.Drawing.Point(160,300)
$ThanksButton.AutoSize = $True
$ThanksButton.Text = "Have a nice day, close"
$ThanksButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.CancelButton = $ThanksButton
$form.Controls.Add($ThanksButton)
$Form.Controls.Add($Label)
$objForm = New-Object System.Windows.Forms.Form 
$objForm.Text = "Timer Example"
$objForm.Size = New-Object System.Drawing.Size(330,380) 
$objForm.StartPosition = "CenterScreen"
$Form.ShowDialog()

 

Save the script as .ps1 extension.

Here is the outcome: