locked
Windows Server 2012 - Powershell script to "allow new connections" for all servers in collection RRS feed

  • Question

  • Hi Guys

    I have a request. When doing maintenance on a Remote Desktop Session Host farm, we sometimes change the "Allow New Connection" from true to false.

    The issue is, that we have experienced that this value is accidential not changed back to true by the technician when maintenance is finished. This is resulting in next morning, alle users are not loggin in to all servers.

    I want to run a Powershell script every night, that changes this value to true. Unfortunately, I have not been able to find any cmdlets, that can help me with this. Is that correct? If not, could you help me here?

    Best regards,

    Mr. Thomas

    Friday, March 6, 2015 8:40 AM

All replies

  • Here you go, Script rattles through all RDSH boxes in a collection, looks for any that are not set to allow new connections and changes them back.

    foreach 
          ($HostToEnable in 
          (get-rdsessionhost -collectionname WebOrderFarm |
           where {$_.NewConnectionAllowed -ne "Yes"}
          )
          )
    {
    $HostToEnable
    set-RDSessionHost $HostToEnable.SessionHost -NewConnectionAllowed "YES"
    }


    • Proposed as answer by Microsoft Jim Friday, March 6, 2015 10:16 AM
    Friday, March 6, 2015 10:16 AM
  • Hello, how do you force a server that is offline to go from True to False?
    Tuesday, March 20, 2018 11:10 AM