Micha Wets

Micha Wets

Cloud.Architect Blog

Micha Wets

5 minutes read

Introduction

After releasing my Powershell Module ExportImportRdsDeployment here, which helps you to migrate your RDS deployment to a newer version, I got some great feedback from users. So it was time to implement some feature requests and improve some things from the first version. The ExportImportRdsDeployment module has been updated and it has Backup functionalities now…

Updating the Module

The module is again available in the Powershell Gallery, so you can easily install and use it on any Windows Server. Make sure you download and use version 2.0.

To check your current version:

Get-Module -ListAvailable ExportImportRdsDeployment

Check current version

If you already have version 1.0 or 1.1, I would suggest you uninstall these versions, and install the latest. To do this, you simply execute this commands:

Uninstall-Module ExportImportRdsDeployment -Force
Install-Module -Name ExportImportRdsDeployment -Force
Get-Module -ListAvailable ExportImportRdsDeployment

Install newest version

Now you can import the module again and start using the updated cmdlets

Import-Module ExportImportRdsDeployment

Import the module

The changes

Get-Help improvement

I improved the instructions and help you get when using the Get-Help cmdlet. You get more information and updated examples for all 4 cmdlets in the module.

Example:

Get-Help Export-RDCollectionsFromConnectionBroker -Detailed

Get Help improvements

Optional removal of collections & servers from deployment

In the previous version, when you executed the Export-cmdlets, the collections & the servers were removed from the deployment.

In the new version, you can export the collections or export the servers using the Export-cmdlets, without the removal functionality. This way,

  • You can test the export and validate the migration before performing the actual migration.
  • You can use the module to create daily backups of your deployment/collections and quickly restore in case of issues or wrong manipulations on your deployment.

This is how you do it:

The Export-cmdlets are in Export-Only mode by default. So if you run the cmdlet as you did before, no removal will be performed at the end of the export.

Export-RDCollectionsFromConnectionBroker -ConnectionBroker localhost

Export-RDDeploymentFromConnectionBroker -ConnectionBroker localhost

You can specifically declare this too, to make sure no removal is executed, using the RemoveCollections & RemoveServers switch-parameters:

Export-RDCollectionsFromConnectionBroker -ConnectionBroker localhost -RemoveCollections:$false -Verbose
Export-RDDeploymentFromConnectionBroker -ConnectionBroker localhost -RemoveServers:$false -Verbose

If you want to perform the migration, you must specify the -RemoveCollections or -RemoveServers parameter and confirm the export with removal. With this safety feature, you cannot mistakenly remove anything.

Confirm export

Reboot Pending check when importing

When running the Import-RDDeploymentToConnectionBroker cmdlet, the module will check if there is a Reboot pending on the target machines (in the export XML file). If there are reboots pending, you can let the cmdlet try to reboot the VMs, or do it manually. You cannot continue with the import until the servers are rebooted.

Reboot pending overview

File access test for XML file

Before performing an export, the cmdlet will test if you have permissions and access to the XMLFile location you have specified (or to the default location). If you do not have access, the cmdlet will stop the export.

Export before removing

When performing an export with -RemoveCollections or -RemoveServers parameter, the cmdlet will first perform the export to the XMLfile before removing the collection/deployment. The writing to the XMLfile must succeed first before continuing.

[Microsoft.RemoteDesktopServices.Management.RDSessionCollectionType] on a Windows 2012 machine

On a Windows 2012 machine, the cmdlet will correctly check for the [Microsoft.RemoteDesktopServices.Management.RDSessionCollectionType] when exporting/importing.

Conclusion

With this update to the module, you should be able to migrate your entire deployment more easily than before, again on any platform (like Azure) and faster than performing an in-place upgrade.

If you have any questions or feature requests, do not hesitate to contact me using the comments, or via Twitter/LinkedIn.

 

 

 

Comments

Previous Comments

David August 12, 2019 at 8:23 pm
 

Hi – wondering if these pw modules would work for migrating 2016 to 2019 RDS?

Micha Wets

August 12, 2019 at 7:29 pm

 

Hi David,

Absolutely! They have been tested from 2012 to 2016 and to 2019, so you should be able to use them!

Claud January 9, 2020 at 7:26 pm
 

Hi Micha, in the import asks to restart servers but when giving “yes” a message appears and stops. Although I restart the servers manually it does not detect the restart in the powershell. ExportImportRdsDeployment 2.0

WARNING!!
Some servers have a reboot pending (or unavailable to query for Reboot Pendings)
If you continue, the import might fail!
Do you want to reboot the servers?
————–
Reboot servers? (Y/N): y
Failed to restart the computer TM520052010 with the following error message: A system shutdown is in progress.
At C:\Program Files\WindowsPowerShell\Modules\ ExportImportRdsDeployment\2.0\ExportImportRdsDeployment.psm1:159 char:5
+ $scriptResult = Invoke-Command -ComputerName $serverName -ScriptB …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (TM520052010:String) [Restart-Computer], InvalidOperationException
+ FullyQualifiedErrorId : RestartcomputerFailed,Microsoft.PowerShell.Commands.RestartComputerCommand

Micha Wets

January 9, 2020 at 9:48 pm

 

Hi,

The function in my module will perform an invoke-command to the remote server, and run Restart-Computer.
The message you got back is returning that the server is indeed still in shutdown mode!

Are you really sure the reboot is executed? If you login to the server, can you check the Running Time from the server in the Task Manager.
Then do a reboot and recheck the Running Time in the Task Manager.
Then rerun the cmdlet.

Kind regards,
Micha

Maciej January 29, 2020 at 11:30 am
 

Hallo Micha, i need to migrate broker with 140 host servers, however it stuck on checking pending reboots on servers, any idea why? I have waited like a 2 hours but no result.

Kind regards,
Maciej

Micha Wets

March 17, 2020 at 5:30 pm

 

Hi Maciej,

Sorry for the delay, your comment must have slipped into the spam.

To check the reboot_pending status, the server you are using to run the cmdlets need to have access to the remote servers.
Do you have a FW blocking Remote Powershell? This is a real requirement to be able to run Remote Powershell commands to all servers in your environment.

Kind regards,
Micha

Recent posts

See more

Categories

About

I started as a junior System Engineer in 2005, but over the years, I acquired more knowledge & skills as a DevOps engineer and have in depth knowledge of private, hybrid and public clouds.
I founded my company to use this experience & knowledge to assist companies with their current & new projects.
In December 2018, I became Microsoft MVP on Windows Virtual Desktop