|This Feature was released as part of version 2.7.0.|
Scripted Actions serve as a Library of PowerShell scripts that can be run in either Azure or AVD Virtual Machines as an included step for various tasks performed by Nerdio Manager. There are two types of Scripted actions: Azure Runbooks and Windows Scripts. Each differ by where they are run respectively:
Read the corresponding Knowledge Base articles for details specific to each type:
You can find scripted actions on the sidebar of the Nerdio Portal:
The Scripted Actions page will look similar to this:
Note: Azure Runbooks must be enabled manually. See the corresponding article for details: Azure Runbooks
Create a Scripted Action
Click "Add Scripted Action" button located at the bottom right of the Scripted Action Page.
The following Fields will be presented:
Name: The name displayed when selecting from the list of available scripted actions.
Description: Description for use within NMW. This only appears on the Scripted Actions page.
Tags: Used for searching and organization
Script Execution Mode: This will dictate how NMW will act when passing the scripted action(s) to the VM. NMW uses the "Custom Script" Extension to ultimately execute the PowerShell commands. (You can read more here.) The extension needs to be installed and removed every time it is used, and will add to the total time to execute for each time it does. Some PowerShell scripts can be combined together and passed with a single run if they do not interfere with each other, saving time.
- Combined Marks the scripted action as one that can be combined safely with other scripted action. An example would be a scripts that adds a registry value.
- Individual Scripts that should be run on their own. An example is a long script with commonly used variable names or require a fresh PowerShell session.
- Individual with Restart Similar to Individual option, but will tell NMW to restart the VM after execution. These are generally used when installing software or altering windows in a manner that requires a restart to apply changes. (Windows Scripts Only)
Script: The PowerShell code that will be executed. You can pass variables into this code that Nerdio will replace dynamically depending on where it is run. Hover over the info icon to see more details.
Choose the settings that work best for the Script, and input PowerShell code to be executed in the Script section.
|Tip: It is recommended to develop code using an IDE such as VSCode or ISE. Then test the PowerShell code on a dedicated "development" session host/azure VM.|
Use a Scripted Action
Scripted Actions can be used as part of the following tasks:
VM Provisioning - Executed during the Provisioning/re-imaging of Session Host VMs. Whenever a session host is created, either from scratch or during re-imaging (which is essentially re-building the VM), the scripted action will be preformed as a final step.
This is edited via the hostpools page -> drop down next to hostpool -> properties -> VM Deployment.
Run Command - Manually run a command against a host pool. Useful if you simply need to alter all the session hosts without fully re-imaging them. I.e. A script to change a registry key.
This is done by going to hostpools page -> drop down -> hosts -> run command.
Default Nerdio Scripts
Every Nerdio installation will come with default scripted actions. These are commonly used scripts and examples that you can use or reference for your own scripts. Default Scripts will have the "Nerdio" Tag, and are unable to be edited. You will need to clone them in order to create an editable copy.
Default Windows Scripts
|Name||Use Case||Recommended Target||Requires Customization*|
|Install MS Teams||Convenient script to save time manually uninstalling and reinstalling teams. Also enables AVD Mode||Image VMs (preferred), Session Hosts||No|
|Install MS 365 Office Apps||Convenient script to save time manually updating office apps||Image VMs||Yes - If the default list of apps installed is not desired|
|Virtual Desktop Optimization||Optimize session hosts for better performance. Commonly used for Remote App Session hosts.||Session Hosts||Yes - By default many apps are removed, such as calculator. If this is undesired, edit them out of the script.|
|Install Zoom VDI Client||Installs Zoom (VDI Version)||Image VMs||No|
|Enable RDP Shortpath||Enables RDP Shortpath||Image VMs or Session Hosts||No|
|Enable AVD Screen Capture Protection||Enables screen capture Protection. Also an example of how to use PowerShell to edit registry via scripted actions.||Image VMs or Session Hosts||No|
|Grant user local admin rights||Adds user who is assigned to the personal desktop VM to the local admin group||Session Hosts||No|
|Update Windows||Runs Windows 10 Updates||Image VMs||No|
Default Azure Runbooks
|Assign Public IP to VM||Allows VM to have a public IP||Yes - If Static IPs are required or naming scheme is undesired|
|Enable Antimalware Extension||Adds anti-malware extension||Yes - If custom exclusions or scan settings times are needed|
|Enable VM OS disk Encryption||Encrypts Disk with Keyvault||Yes - If using an existing keyvault|
*This script is intended to be cloned and edited to suit your needs. It may run fine without alteration, but care should be taken to ensure that the default behavior is desired.
Real World Examples
If you have a software that must be uninstalled from VMs to "reuse" a license, you can create a scripted action to uninstall, go to the host pool -> drop down -> properties -> VM Deployment. Then add the scripted action like so at "Run the following Powershell Commands when the VM is:" and select "Removed"
A few registry keys need to be changed, and you do not wish to have to re-image the entire pool to do so. A scripted action such as the "Enable AVD Screen Capture", which simply adds a registry key, can be run against the session hosts.