Skip to main content

Scripting for Multiple Launchpads with Frame

· 7 min read
Justin Emilio

Scripting for Multiple Launchpads with Frame

The Nutanix Frame platform offers customers the option to create multiple user interfaces through the use of Frame Launchpads. These Launchpads allow customers to customize their environment and create custom apps that are tailored to specific end users and workflows. Each account can have multiple Launchpads to cater to different use cases and workloads (Read more about Frame Launchpads here).

We can further customize a user's experience by using PowerShell scripts to modify the remote Windows environment. These scripts can be used to automate tasks and customize the appearance and functionality of the user interface. These scripts are called FGA Scripts (More about FGA Scripts).

As an example, a customer may use PowerShell scripts to install additional software or tools that are not already included in the Nutanix Frame environment. This can be helpful for users who have specific requirements or preferences for the tools they need/use. Additionally, PowerShell scripts can be used to customize the appearance of the user interface, such as by changing the background, font colors, or adding custom logos with branding.

This blog will demonstrate how to write a custom pre-session FGA script that has the ability to determine which Launchpad was used to start a session, and make changes to the environment that were tailored for the audience of the chosen Launchpad.

For the purposes of this blog, let’s assume we have two different types of end users for the same Frame account (Elves and Dwarves). However, we want to have a very different greeting for each type of user when they start a session. For every time a Dwarf starts a session in the “Dwarven” Launchpad, a background of the finest Craftsdwarfship will be used to display the many wonderful examples of art that are specific to what a Dwarf might want to see. We will choose an equally wonderful example of what an Elf would want to see should an Elf start a session from the “Elven” Launchpad.

As you can see, it is very important that you do not mix up these two environments as it might offend a Dwarf if they get an Elven environment and vice versa. Overall, the goal is to create a personalized and enjoyable experience for each user group by providing them with customized environments that are relevant to their interests and preferences.

If we were to write a pre-session PowerShell script that determines the chosen Launchpad, we can also use this same Powershell script to change the Windows background image to the corresponding Launchpad’s assigned wallpaper.

Consider the following PowerShell script that outlines our intentions (Set-Wallpaper function is defined in the final code at the end of the blog):

# Get the value of the FRAME_SESSION_LABEL environment variable
$frameSessionLabel = Get-ChildItem Env:FRAME_SESSION_LABEL

# Use a switch statement to execute different code blocks based on the value of $frameSessionLabel
switch ($frameSessionLabel)
{
"Launchpad-Elves" {
# Code to execute if $frameSessionLabel is "Launchpad-Elves”
Write-Host "You are using the Launchpad intended for Elves"
Set-Wallpaper(“URLToElvesImage.PNG”)
}

"Launchpad-Dwarves"
{
# Code to execute if $frameSessionLabel is "Launchpad-Dwarves"
Write-Host "You are using the Launchpad intended for Dwarves"
Set-Wallpaper(“URLToDwarvesImage.PNG”)
}

default {
# Code to execute if $frameSessionLabel is neither of the intended Launchpads
Write-Host "Unable to determine Launchpad"
}
}

This script first extracts the value of the "FRAME_SESSION_LABEL" environment variable using the Get-ChildItem cmdlet. The script then uses a switch statement to evaluate the value of $frameSessionLabel and execute a different code block based on the result. If the value of the environment variable is "Launchpad-Elves", the script will output "You are using the Launchpad intended for Elves" and change the wallpaper. If $frameSessionLabel is "Launchpad-Dwarves", the script will output "You are using the Launchpad intended for Dwarves" and update the wallpaper. If $frameSessionLabel is neither of these values, the script will output "Unable to determine the Launchpad you chose".

After reviewing the script, you will have to ask the question “Where did the FRAME_SESSION_LABEL Environment Variable come from”? The answer to this question is actually a manually entered field in the Frame Account Dashboard under the “Session Settings” section for each individual Launchpad, as shown below.

Session Settings

Once you go into the “Session Settings” for this Launchpad, you will need to add the following arguments to the “Advanced Server Arguments” field at the bottom of the pop-up window as depicted by the screenshot below.

Everything is verbatim and required. Replace the underlined text with anything you want (No spaces or special characters. Just alphanumeric).

Advanced Server Arguments

-frame-session-label=justin_custom_launchpad_label

The value you put into this argument is what will be returned by the Environment Variable FRAME_SESSION_LABEL in the remote Windows environment.

Environment Variable

Put a unique identifier into this argument for every Launchpad that you wish to handle in your PowerShell script.

Now that we’ve covered everything that is required for this solution, let’s actually put everything in place to test the solution. We’ll add more code to the PowerShell script above that can change the wallpapers, but the rest of the code should be self-explanatory. Let’s put this together in step/list form:

  1. Create a PowerShell script in the Sandbox environment. This is going to be an FGA Pre-Session script, and it needs to be saved to the C:\ProgramData\Nutanix\Frame\FGA\Scripts\User folder. Let’s name it pre-session.ps1.
  2. Insert the following code into the script. Use any editor you want, but know that the powershell_ise.exe editor comes with Windows and is designed for PowerShell (Make sure you update the URLs to a local or remote location of where the wallpapers reside):
function Set-Wallpaper([string]$wallpaperUrl)
{
# Get the path to the current user's wallpaper image file
$wallpaperPath = "$($env:PUBLIC)\Desktop\wallpaper.png"

# Download the new wallpaper image from the provided URL and save it to the wallpaper path
Invoke-WebRequest -Uri $wallpaperUrl -OutFile $wallpaperPath

# Set the new wallpaper image as the desktop background
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop\' -Name Wallpaper -Value $wallpaperPath
}

# Get the value of the FRAME_SESSION_LABEL environment variable
$frameSessionLabel = Get-ChildItem Env:FRAME_SESSION_LABEL

# Use a switch statement to execute different code blocks based on the value of $frameSessionLabel
switch ($frameSessionLabel)
{
"Launchpad-Elves" {
# Code to execute if $frameSessionLabel is "Launchpad-Elves”
Write-Host "You are using the Launchpad intended for Elves"
Set-Wallpaper(“URLToElvesImage.PNG”)
}

"Launchpad-Dwarves"
{
# Code to execute if $frameSessionLabel is "Launchpad-Dwarves"
Write-Host "You are using the Launchpad intended for Dwarves"
Set-Wallpaper(“URLToDwarvesImage.PNG”)
}

default {
# Code to execute if $frameSessionLabel is neither of the intended Launchpads
Write-Host "Unable to determine Launchpad"
}
}

  1. Add the following lines to your definition.yml file in the same folder (Should already exist). See more about this topic on our docs page (Scripting):
    -
desc: Scripts before session is started
name: pre-session
timeout: 30
run-policy: pre-session
pool-type:
- production
scripts:
-
desc: My script to change the wallpaper based on the Launchpad used
path: pre-session.ps1
error-policy: continue
timeout: 20

  1. Close the session on the Sandbox
  2. Go into the Elves Launchpad Session Settings (as shown above). Add the following line to the Advanced Server Argument field: -frame-session-label=Launchpad-Elves
  3. Do the same for the Dwarves Launchpad with the following line: -frame-session-label=Launchpad-Elves
  4. After this is done, you will now need to publish the Sandbox to your Production pool.

After the Sandbox has been published, you can test this solution by starting a session from any of the two Launchpads from the Elves or Dwarves. If the proper Wallpaper shows up, you have successfully implemented the solution.

To make this script even more useful, you could add logging to your FGA pre-session script and track which Launchpad was chosen (for auditing purposes). If you are running this pre-session script on a non-persistent Frame account, logs written to the local disk will be lost. You can always use network shares or remote logging services to host these logs (Splunk, Loggly, etc.).

Conclusion

This blog post demonstrates how to create tailored user experiences using Nutanix Frame Launchpads and PowerShell FGA scripts. This is only one example of the unlimited possibilities and customizations that can be implemented for your end users.

Make sure to browse/read through our Frame API/scripting documentation to give you a better understanding of the possibilities (and hopefully trigger some creative ideas for your end users’ experiences).

Contact Us

Need help with your Frame deployment, have an idea for a new use case, or just want to learn more about Frame?

Email us at frame-sales@dizzion.com and one of our experts will reach out!

Follow Us

LinkedInTwitter
#workfromframe
Justin Emilio

More content created by

Justin Emilio
Justin Emilio is a Senior Solutions Architect with Frame.

© 2024 Dizzion, Inc. All rights reserved. Frame, the Frame logo and all Dizzio product, feature and service names mentioned herein are registered trademarks of Dizzion, Inc. in the United States and other countries. All other brand names mentioned herein are for identification purposes only and may be the trademarks of their respective holder(s). This post may contain links to external websites that are not part of Dizzion. Dizzion does not control these sites and disclaims all responsibility for the content or accuracy of any external site. Our decision to link to an external site should not be considered an endorsement of any content on such a site. Certain information contained in this post may relate to or be based on studies, publications, surveys and other data obtained from third-party sources and our own internal estimates and research. While we believe these third-party studies, publications, surveys and other data are reliable as of the date of this post, they have not independently verified, and we make no representation as to the adequacy, fairness, accuracy, or completeness of any information obtained from third-party sources.