AVD Web Launcher Using Only “Local Stuff”

AVD

I recently wrote a blog post on how to build your own web launcher for AVD: Build Your Own Web Launcher for AVD – Azure Advanced Migration Topics for Government (azurewebsites.us)

That post showed how to pull most of the necessary information from Azure to create a web page to launch sessions using the Windows Remote Desktop client.

It is possible to pull all the necessary information right from the client PC (assuming the user has already “subscribed” to the workspace… which isn’t needed if you pull the info from Azure).

In this post, I want to walk through an example of building an AVD web launch page using only local information from the client PC.

As I mentioned, this method does require the user to have already subscribed to a workspace – which I have done:

Once a user successfully subscribes to AVD on a Windows PC, lots of great information is saved to the system to do things like add shortcuts the Start Menu – which are stored below
C:\Users\<userID>\AppData\Local\rdclientwpf

All sorts of AVD files can be found on the local system here, including RDP, ICO, and PNG:

Those icons are nice… they can make your web page look very pretty, but the key thing to know is that the AVD Workspace Object IDs and Application Object IDs are accessible! Those are key ingredients in crafting URI to launch an AVD session (which is documented here: Uniform Resource Identifier schemes with the Remote Desktop client for Azure Virtual Desktop (preview) | Microsoft Learn).

Since I’ve already walked through the detail of the URI in my previous post, I’ll spare you the details and jump right to the output and the code!

Here’s the sample code:

#########################################################################
#  Assumes AVD user has already logged into Windows Remote Desktop Client,
#  Only one user ID has been "subcrived, and 
#  Configuration is stored on C: drive
#
# Get local userID
#
$Shell = New-Object -ComObject ("WScript.Shell")
$ShortCut = $Shell.CreateShortcut($env:USERPROFILE + "\downloads\Comet.url")
#########################################################################
# Get local AVD stuff
#
$webfile = "C:\Users\" +  $env:USERNAME + "\downloads\myfile.html"
$JSONfile = "C:\Users\" +  $env:USERNAME + "\AppData\Local\rdclientwpf\" + "ISubscription.json"
$AVDInfo = type $JSONfile | ConvertFrom-Json 
$WorkSpaceOID = $AVDInfo.TenantCollection.TenantID
$User = $AVDInfo.Username
#
########################################################################
# Write out HTML File Header
#
new-item $webfile -itemtype File -force
# Added some HTML Formating John Wilson
add-content $webfile "<!DOCTYPE html>`n<html>`n<body>`n`n<h1>AVD Applications & Desktops</h1>`n"
#
#######################################################################
# Write out Application ICONS
#
foreach ($App in $AVDInfo.TenantCollection.remoteresourcecollection) {
	$AppName = $App.Title
	$URL = -join("ms-avd:connect?workspaceId=", $WorkSpaceOID, "&resourceid=", $app.ID, "&username=",  $User, "&version=0")
	$IconPath = $app.Iconpath -replace "\\","/"
	$IconPath = $IconPath -replace "C:/", "C:///"
	add-content $webfile "`n<p style=`"border: 1px solid black`">`n<h3>$AppName</h3>`n<a href=`"$URL`">`n`t<img src=`"file:///$IconPath`" alt=$AppName style=`"width:25%`"></a>`n</p>`n`n"
}
add-content $webfile "`n`n</body>`n</html>"
###################################################################
# open up new custom web page!
#s
Invoke-item $webfile
#################################################################

…and here’s what the webpage looks like that it generated:

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top