troubleshooting Question

Query for first name and add to powershell forms string

Avatar of Mase2k
Mase2kFlag for United States of America asked on
PowershellActive Directory
3 Comments1 Solution66 ViewsLast Modified:
I am trying to figure out how to query for Active Directory Display Name and then enter it into the string below where you see (Insert first name here). This is a Powershell script which I am running to announce to users that their application is launching. Trying to personalize the popup. Everything works with the exception of the users name appearing.

Function Generate-Form {
    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 (Insert first name here)! Please wait while your application is launching.

This box will close automatically."
    $objForm.Controls.Add($objLabel)
    $objForm.Show()| Out-Null
    Start-Sleep -Seconds 5
    $objForm.Close() | Out-Null
}
generate-form
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros