In this Wiki we will perform actions related to RemoteApps in Windows Server 2012 by making use of PowerShell including, but not limited to:
  • Creating RemoteApps
  • Creating Subfolders
  • Setting File Extensions

(More Wiki's on the RemoteDesktop PowerShell module in Windows Server 2012: http://social.technet.microsoft.com/wiki/contents/articles/12835.using-powershell-to-install-configure-and-maintain-rds-in-windows-server-2012.aspx )

Creating RemoteApps

The RemoteDesktop PowerShell module also has the ability to create, update and delete RemoteApps. There is a PowerShell command to retrieve RemoteApps and their properties from a specified Collection and RD Connection Broker. This cmdlet is Get-RDRemoteApp. For example to retrieve all RemoteApps the following command can be used.



The command to create a new RemoteApp is New-RDRemoteApp.

SYNTAX
    New-RDRemoteApp [-CollectionName] <string> -DisplayName <string> -FilePath <string> [-Alias <string>]
    [-FileVirtualPath <string>] [-ShowInWebAccess <bool>] [-FolderName <string>] [-CommandLineSetting
    <CommandLineSettingValue> {DoNotAllow | Allow | Require}] [-RequiredCommandLine <string>] [-UserGroups <string[]>]
    [-IconPath <string>] [-IconIndex <string>] [-ConnectionBroker <string>]  [<CommonParameters>]

In this example, we create a RemoteApp to deliver WordPad. We use the following command;

new-rdremoteapp -Alias Wordpad -DisplayName WordPad -FilePath "C:\Program Files\Windows NT\Accessories\wordpad.exe" -ShowInWebAccess 1 -collectionname MySessionCollection -ConnectionBroker LS01.CRFB.Local

During the creation of the RemoteApp we are provided with a progress bar.



In addition, when the creation is finished to command output the details of the creation.



When we refresh the Server Manager console we see the RemoteApp successfully added.

The RemoteDesktop module also supplies cmdlets to update RemoteApps (Set-RDRemoteApp) and remove RemoteApps (Remove-RDRemoteApp).

When you create a new RemoteApp using the GUI wizard it would also show a list of available applications that can be added. The equivalent PowerShell Command for this action is Get-RDAvailableApp. Running this command while specifying the connection broker and collection can result in an output as follows:

Creating Subfolders

Using the The RemoteDesktop PowerShell module we're also able to add subfolders in RD Web Access and "move" specific Remote Apps to specific folders. In order to do so we use the same command as above, Set-RDRemoteApp. For example, to create a subfolder called "My Favorite tools" and move the Remote App Wordpad to that folder you can use the following command:

Set-RDRemoteApp -CollectionName MySessionCollection -Alias Calculator -FolderName "My Favorite tools" -ConnectionBroker SH01.CRFB.Local

Note that you need to specify the name of the Session Collection as well as the name of the RD Connection Broker server.

Creating File Extensions

A common setting is configuring the file extensions for Remote Apps. Inside the ServerManager GUI, file extensions are configured as a property of a RemoteApp, therefore you would expect that setting a file extension using PowerShell should be done using the command Set-RDRemoteApp. Instead, we need to use a different command called Set-RDFileTypeAssociation.

SYNTAX
    Set-RDFileTypeAssociation [-CollectionName] <string> -AppAlias <string> -FileExtension <string> -IsPublished
    <bool> [-IconPath <string>] [-IconIndex <string>] [-ConnectionBroker <string>]  [<CommonParameters>]

    Set-RDFileTypeAssociation [-CollectionName] <string> -AppAlias <string> -FileExtension <string> -IsPublished
    <bool> -VirtualDesktopName <string> [-IconPath <string>] [-IconIndex <string>] [-ConnectionBroker <string>]
    [<CommonParameters>]

For example if we want to add the file extension .pdf to a Remote App Acrobat Reader we can use the following command:

Set-RDFileTypeAssociation -CollectionName MySessionCollection -AppAlias AcrobatReader -FileExtension .pdf -IsPublished $true -ConnectionBroker SH01.CRFB.Local



References


See Also