Function Generate-Form {
Param(
[Parameter(Mandatory=$true,
ValueFromPipeline=$true)]
[String[]]
$Name
)
Add-Type -AssemblyName System.Windows.Forms
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "Session is loading . . . "
$objForm.Size = New-Object System.Drawing.Size(400,400)
#$Icon = [system.drawing.icon]::ExtractAssociatedIcon("C:\test.ico")
#$objForm.Icon = $Icon
$objForm.MinimizeBox = $False
$objForm.MaximizeBox = $False
$objForm.WindowState = "Normal"
$objForm.SizeGripStyle = "Hide"
$objForm.ShowInTaskbar = $False
$objForm.StartPosition = "CenterScreen"
$objForm.BackColor = "#DF7A1C"
$Font = New-Object System.Drawing.Font("Times New Roman",18,[System.Drawing.FontStyle]::Regular)
$objForm.Font = $Font
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(40,40)
$objLabel.Size = New-Object System.Drawing.Size(300,300)
$objLabel.Text = "Hello " + $Name + "! Please wait while your application is launching.`n`nThis box will close automatically."
$objForm.Controls.Add($objLabel)
$objForm.Show()| Out-Null
Start-Sleep -Seconds 5
$objForm.Close() | Out-Null
}
$firstame = Get-ADUser -identity $env:username |select-object GivenName
$fn = $firstame.GivenName
generate-form -Name $fn