Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7406533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:34:23+00:00 2026-05-29T05:34:23+00:00

All our testboxes run on VMs (windows server 2003/08) and testers access them via

  • 0

All our testboxes run on VMs (windows server 2003/08) and testers access them via remote desktop only.

Some maintenance steps require to kick all users from the system and deactivate access via remote desktop.

I started to write the maintenance scripts in powershell and am looking for a way to temporarily deactivate remote desktop. Is that possible, any straight-forward solutions to this?

What I have tried so far:

  • A colleague recommended turning-off the netlogon-service, but I can
    still logon with remote-desktop.
  • Another colleague recommended disabling blocking the port for
    remote-desktop with the firewall, but somehow that does not feel
    right to me (?) because I don’t want to change one part of a system
    to affect another part. Am I too picky … ? 😉

Any hints highly appreciated.

Cheers,
Tobi

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:34:24+00:00Added an answer on May 29, 2026 at 5:34 am

    Now I have found a solution that works perfect for me. Windows Server 2008 comes with a feature called “Terminal Services Server Drain Mode“

    … the TS Server Drain Mode prevents new users from logging onto the server, while allowing currently logged on users to reconnect to their existing sessions. By waiting for existing users to save their work and log off, the administrator can take a terminal server down for maintenance without causing user data loss.

    Before I activate the drain mode I ensure that no one is logged in and then I active the drain mode with the following code:

    Invoke-Command -ComputerName myServerHostName -ScriptBlock
    {
       Set-ItemProperty -Path "HKLM:\SYSTEM\Currentcontrolset\control\Terminal Server" -Name TSServerDrainMode -Value 1
    }
    

    Although I am changing a registry key, I am not required to reboot the server for the changes to be effective. This works without a reboot.

    When I am done performing maintenance work I deactive drain mode with “-Value 0” and users are able to log in again.

    Works like a charm!


    My original answer was:

    My perferred solution that I have found through extensive web search is as follows (also untested):

    $Terminal = Get-WmiObject Win32_Terminal –Computer “ComputerName”
    $Terminal.Enable($True)
    

    Other possible and interesting code snippets, or variations on the topic, that I have found:

    $myWmiObject = Get-WmiObject -namespace “rootCIMV2TerminalServices” -class Win32_Terminal -Computer “ComputerName” -Authentication PacketPrivacy

    or

    Set-WmiInstance -namespace “rootCIMV2TerminalServices” -class Win32_Terminal -ComputerName “ComputerName” -Authentication PacketPrivacy -Argument @{fEnableTerminal=0}

    or

    Get-WmiObject -ComputerName “ComputerName” -namespace root/cimv2/terminalservices -class Win32_Terminal -Authentication PacketPrivacy

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our server got hacked via some SQL Injection method (now patched). All our PHP
All our developers are able to log in to our staging server via ssh.
Currently all our files are stored on a Windows network drive and with 15
We store all our dates SQL Server 2008 database in UTC time in DateTime
We run Code Analysis on all our source files. One of our source files
Currently all our GUI components are written in MFC. Our build environment is: VC
we're currently generating all our official documents using XSL-FO transformation using .xml files as
when we write all our application methods and variables in a classes is nothing
We use in all our pages in the 1st line of our HTML code
we're transitioning to doing all our task tracking in TFS 2010 and I'm wondering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.