Use Custom Icons from the filesystem


To set custom images for RoyalObjects via PowerShell you have to use PNG file and encode it with Base64.


$RTSPSModule = Join-Path -Path ${env:ProgramFiles(x86)} -ChildPath 'code4ward.net\Royal TS V4\RoyalDocument.PowerShell.dll'
Import-Module $RTSPSModule

# encode a PNG file base64
$customImagePath = 'C:\temp\a.png'
$Content = Get-Content -Path $customImagePath -Encoding Byte
$Base64 = [System.Convert]::ToBase64String($Content)

# assign it to the RoyalObject
$rtszFile = 'c:\temp\test.rtsz'
$Store = New-RoyalStore -UserName ($env:USERDOMAIN + '\' + $env:USERNAME)
$RoyalDocument = New-RoyalDocument -FileName $rtszFile -Store $Store -Name "testdocument"
$RDS = New-RoyalObject -Folder $RoyalDocument -Type RoyalRDSConnection -Name testrds -Description "Demo server"
Set-RoyalObjectValue -Object $RDS -Property CustomImage -Value $Base64
Out-RoyalDocument -Document $RoyalDocument
Close-RoyalDocument -Document $RoyalDocument



Using Icons from the Royal TS/X Icon Library


If you want to set one of the already existing Icons from our Icon Library, you can use the CustomImage property. It takes the relative path of the Icon to the installation directory of Royal TS.


$flagIcon = "/Flat/Flags/Flag Germany"
...
Set-RoyalObjectValue -Object $RDS -Property CustomImageName -Value $flagIcon



Use Custom Icons from Applications

Royal TS is using some Win32 magic to extract an icon from an external application which is not straightforward to code in PowerShell. Though, there are tools that can extract icons from executables.