Menu
InformatiWeb Pro
  • Index
  • System admin
  • Virtualization

Login

Registration Password lost ?
FR
  • Windows Server
    • WMS 2012
    • WS2012 R2
    • WS2016
  • Citrix
    • Citrix NetScaler Gateway
    • Citrix XenApp / XenDesktop
    • Citrix XenServer
  • VMware
    • VMware ESXi
    • VMware vSphere
    • VMware Workstation
  • Microsoft
    • Hyper-V
  • RAID
    • Adaptec SmartRAID
  • UPS
    • APC Back-UPS Pro
  • InformatiWeb Pro
  • System admin
  • Windows Server
  • Courses
  • Learn how to deploy RDS on WS 2012 and 2012 R2
  • Put a session host into maintenance
25 / 27
  • Set up HA on your RDS infrastructure
  • Unblock a session as admin
  • Windows Server
  • 12 April 2019 at 08:49 UTC
  • InformatiWeb

Put your RDS session host server in maintenance on Windows Server 2012 / 2012 R2 / 2016

When you deploy a RDS infrastructure, you must also maintain and protect it by regularly installing Windows updates and the programs you have installed.
However, since your users are also using this server, you will need to limit access to the server to install these updates.

  1. Notify your users
    1. Via the graphical interface
    2. Via the command line (CLI)
  2. Put the server into maintenance
  3. Disconnect your users
    1. Via the graphical interface
    2. Via the command line (CLI)

1. Notify your users

To begin, the most important thing is to warn your users early enough so that they can save their work before you work on the server.

1.1. Via the graphical interface

For this you can do it through the GUI, through the Server Manager -> Remote Desktop Services -> Collections.
In the "Connections" list, you will see the list of users connected to your RDS server.

The only disadvantage of doing this via the graphical interface is that you will not be able to send a message to all your users in 1 click.
Indeed, you will have to right click "Send a message" on each connected user.

This can become impossible if you have dozens or even hundreds of users connected to your server.

Via this feature, you will be able to specify :

  • a title : Scheduled Maintenance
  • a message : Warning: the server will be under maintenance at 17:15! Please save your work and close your session.

Then, click on Send.

Once sent, this is what the user will see on his screen.

1.2. Via the command line (CLI)

If you go through the command line, you can send a message to all users of the server in one command.

Plain Text

msg * "message to send to all users"

Note : the asterisk (*) is used to target all users.

If you want to send a more professional message, with newlines, use the command like this :

Batch

msg *

In this case, the command will wait for you to type your message.

Plain Text

Enter message to send; end message by pressing CTRL-Z on new line, then ENTER

Type your message. For example :

Plain Text

Warning : the server will be under maintenance at 17:35 ! Please save your work and close your session.

Sincerely, your system administrator
^Z

Once you have validated your message by the combination "CTRL + Z" on a new line, then ENTER, the message will appear on the screen of all your users.

But, as you can see, by default, the msg command causes an encoding error.
Indeed, the message you write in the console (OEM 850) is not encoded in the same way as Windows (windows-1252).
There will be display problems for accented characters.

To solve the problem, simply change the encoding used by the command prompt temporarily by typing this command :

Batch

CHCP 1252

Now, the command prompt will use the same encoding as Windows.
Type the command again :

Batch

msg *

Type your message as before (ignoring the fact that accented characters don't display correctly in the command prompt).

Once you have validated sending the message, you will see that it will appear correctly.

2. Put the server into maintenance

In reality, there is no maintenance mode on RDS.
Nevertheless, it's possible to :

  • block new connections to the server
  • disconnect users from the server
  • OR close their sessions with one command

To get started, go to "Server Manager -> Collections" and right click "Do not allow new connections" on your RDS server.

Click Yes.

3. Disconnect your users

3.1. Via the graphical interface

To disconnect your users, you have 2 possibilities :

  • disconnect them only : to keep the programs open and avoid losing the work done by your users
  • close their session : to also close the programs which would have remained open and which would prevent, if necessary, to update them

If you go through the server manager, you will be able to choose :

  • Disconnect : to disconnect the user
  • Log off : to log off

Once you disconnect or log off the user, they will receive an error "Your Remote Desktop Services session has ended".

3.2. Via the command line (CLI)

At the moment, 1 user and you as an administrator are connected.

To disconnect all users, you can rely on a script provided by Microsoft.

Batch

query session >session.txt
for /f "skip=1 tokens=3," %%i in (session.txt) DO tsdiscon %%i
del session.txt

On the user side, you will see this error message : Your Remote Desktop Services session has ended.

Note that you will also be disconnected and the script will disconnect only users who have logged in before you.
To disconnect the rest of the users, you may need to reconnect and restart the script a second time.

As you can see through the task manager, other users will be in "Disconnected" status.

Note that a disconnected user can still reconnect because it's a reconnection to an existing session and not a new connection.

If you want to prevent your users from reconnecting during maintenance, you will need to log out them.

To do this, use the Microsoft script (whose link has been indicated previously).

Batch

query session >session.txt
for /f "skip=1 tokens=3," %%i in (session.txt) DO logoff %%i
del session.txt

Once the script has finished closing all sessions, log back in as an administrator and you will find that there are only you on the server.

Also, since new connections are prohibited, your users will not be able to reconnect to your RDS server until maintenance is complete.

Share this tutorial

Partager
Tweet

To see also

  • WS 2012 / 2012 R2 - RDS - Set up HA on your RDS infrastructure

    Windows Server 6/7/2019

    WS 2012 / 2012 R2 - RDS - Set up HA on your RDS infrastructure

  • WS 2012 / 2012 R2 / 2016 - RDS - Access RemoteApp via a modern application

    Windows Server 3/8/2019

    WS 2012 / 2012 R2 / 2016 - RDS - Access RemoteApp via a modern application

  • WS 2012 / 2012 R2 / 2016 - RDS - Attempt to unblock the session as a user

    Windows Server 4/28/2019

    WS 2012 / 2012 R2 / 2016 - RDS - Attempt to unblock the session as a user

  • WS 2012 / 2012 R2 / 2016 - RDS - Change the properties of RemoteApps

    Windows Server 3/16/2019

    WS 2012 / 2012 R2 / 2016 - RDS - Change the properties of RemoteApps

Comments

You must be logged in to post a comment

Share your opinion

Pinned content

  • Software (System admin)
  • Linux softwares
  • Our programs
  • Terms and conditions
  • Share your opinion

Contact

  • Guest book
  • Technical support
  • Contact

® InformatiWeb-Pro.net - InformatiWeb.net 2008-2022 - © Lionel Eppe - All rights reserved.

Total or partial reproduction of this site is prohibited and constitutes an infringement punishable by articles L.335-2 and following of the intellectual property Code.