If you build a new RDS environment for what ever reason and you have a lot of published remote apps and you don’t want to recreate them by hand you have to use some scripting.
Variables
1 2 3 4 5 6 7 8 |
### Old environment $ConnectionBrokerOLD = "Old broker" $CollectionNameOLD = "Old Collection name" ### New environment $ConnectionBrokerNEW = "New broker" $CollectionNameNEW = "New Collection name" ### Export path $ExportPath = "C:\RemoteApp\Export.csv" |
Export All Remote Apps from the old RDS Farm
1 |
Get-RDRemoteApp -CollectionName $CollectionName -ConnectionBroker $ConnectionBrokerOLD | Export-Csv -Path $ExportPath -NoTypeInformation |
Now just import the RemoteApps by using the foreach-object powershell command.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Import-Csv -Path $path | ForEach-Object { If ($_.CommandLineSetting -eq "Require" ) { Write-Host "This RemoteApp ("$_.Alias") has a Required CMDLine" New-RDRemoteApp -CollectionName $CollectionNameNEW -ConnectionBroker $ConnectionBrokerNEW -Alias $_.Alias -DisplayName $_.DisplayName -FilePath $_.FilePath -FileVirtualPath $_.FileVirtualPath -FolderName $_.FolderName -IconPath $_.IconPath -IconIndex $_.IconIndex -CommandLineSetting Require Start-Sleep 45 Write-Host "Now updating RemoteApp " ($_.Alias) "" Get-RDRemoteApp -CollectionName $CollectionNameNEW -ConnectionBroker $ConnectionBrokerNEW -Alias $_.Alias | Set-RDRemoteApp -CollectionName $CollectionNameNEW -RequiredCommandLine $_.RequiredCommandline } else { Write-Host "this RemoteApp ("$_.Alias") does not have a Required CMDLine" New-RDRemoteApp -CollectionName $CollectionNameNEW -ConnectionBroker $ConnectionBrokerNEW -Alias $_.Alias -DisplayName $_.DisplayName -FilePath $_.FilePath -FileVirtualPath $_.FileVirtualPath -FolderName $_.FolderName -IconPath $_.IconPath -IconIndex $_.IconIndex } } |
Helpful, however there are two errors in the code:
1) Get-RDRemoteApp -CollectionName $CollectionName — variable $CollectionName is not defined, should be $CollectionNameOLD
2)Import-Csv -Path $path — again $path is not defined, should be $ExportPath