PowerShell: Create a Graphical Desktop Shortcut with Computer Info and Link to the Ticket System (Helpdesk)

As adminstrator you are not only responsible for assigning group policies or playing the cop who always watch what users do or not. A major part of your duties is to make sure your users can work as comfortably as possible. This is what this blog post is about. I will show you a code sample which creates a graphical desktop shortcut icon. With this dektop icon users can get infos about their computer and – if needed – a link to the IT ticket system.

The Objective

The objective is to make this screen happen when a users klicks on a shortcut on his desktop.

Anmerkung 2020-04-18 102203.png

All this contributes to the fact that the user can easily retrieve information about his computer and contact the helpdesk with this information.

Which brings me to the next part. It’s about the code behind this pop-up window.

The Code (WindowsForms)

You can create a pop-up window in PowerShell in two main ways: VB and WindowsForms. I decided to go with Windows Forms so the code below is written with Forms.

Important Notes

Code tested in PowerShell 5.1 and PowerShell 7.

You certainly want to customize the sample code. I have prepared some useful tips and a reference to the lines which should be adapted.

Line 9: edit head

Line 12: icon edit top left (if icon is missing, default icon is used)

Line 29,30: edit link text and hyperlink to help system

And finally, here is the code.

Copy it into your favourite editor such as PowerShell ISE or VS Code.

$ErrorActionPreference = "SilentlyContinue"

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

$font = New-Object System.Drawing.Font("Arial", 9)

$form = New-Object System.Windows.Forms.Form
$form.Text = 'Computer-Info'
$form.Size = New-Object System.Drawing.Size(325,225)
$form.StartPosition = 'CenterScreen'
$form.Icon = 'C:\users\patri\OneDrive\Bilder\favicon.ico'

$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Point(120,150)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = 'OK'
$OKButton.TextAlign = 'MiddleCenter'
$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $OKButton

$LinkLabel = New-Object System.Windows.Forms.LinkLabel
$LinkLabel.Location = New-Object System.Drawing.Point(81,110)
$LinkLabel.Size = New-Object System.Drawing.Size(280,20)
$LinkLabel.Font = $font
$LinkLabel.LinkColor = "BLUE"
$LinkLabel.ActiveLinkColor = "RED"
$LinkLabel.Text = "Ticketsystem"

$hostn = New-Object System.Windows.Forms.Label
$hostn.Location = New-Object System.Drawing.Point(10,10)
$hostn.Size = New-Object System.Drawing.Size(280,20)
$hostn.Font = $font
$hostn.Text = "Computer: $(hostname)"

$os = New-Object System.Windows.Forms.Label
$os.Location = New-Object System.Drawing.Point(10,90)
$os.Size = New-Object System.Drawing.Size(280,20)
$os.Font = $font
$os.Text = "OS: $((Get-CimInstance win32_operatingsystem).Caption.Trimstart('Microsoft '))"

$mac = New-Object System.Windows.Forms.Label
$mac.Location = New-Object System.Drawing.Point(10,50)
$mac.Size = New-Object System.Drawing.Size(280,20)
$mac.Font = $font
$mac.Text = "MAC: $((Get-NetAdapter | Where-Object Status -EQ 'up').MacAddress)"

$user = New-Object System.Windows.Forms.Label
$user.Location = New-Object System.Drawing.Point(10,30)
$user.Size = New-Object System.Drawing.Size(280,20)
$user.Font = $font
$user.Text = "User: $env:username"

$ip = New-Object System.Windows.Forms.Label
$ip.Location = New-Object System.Drawing.Point(10,70)
$ip.Size = New-Object System.Drawing.Size(280,20)
$ip.Font = $font
$ip.Text = "IP: $((Get-NetAdapter | Where-Object Status -EQ 'up' | Get-NetIPAddress -AddressFamily IPv4).IPAddress)"

$help = New-Object System.Windows.Forms.Label
$help.Location = New-Object System.Drawing.Point(10,110)
$help.Font = $font
$help.Size = New-Object System.Drawing.Size(280,20)
$help.Text = "Help:"

$form.Topmost = $true


Now it’s your turn to distribute the code as a link to your workstations via GPOs.

See also


Categories: PowerShell, Windows 10

Tagged as: , ,

5 replies »

  1. When using this on VPN and with Vmware Workstation installed you get a lot of ‘false’ information. How to exclude these?


  2. Hello Patrick, how are you? Please do you help me. I can`t create GPO for your upstair script. Please do you help me. I create GPO in my domain, but when I click to script, nothing doesn`t happen.


  3. Hallo Patrick, how are you today? Your script is beautiful. I have 2 questions for you. First is how can I put on desktop (using shortcut) and Secon question is how Can I distribute via GPO in whole domain


Leave a Reply to Michael Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.