SetAllowTSConnections Method of the Win32_TerminalServiceSetting Class

The SetAllowTSConnections method sets the AllowTSConnections property for the class.

Syntax

MOF
uint32 SetAllowTSConnections(
  [in]  uint32 AllowTSConnections,
  [in]  uint32 ModifyFirewallException
);

Parameters

AllowTSConnections [in]

Flag enabling or disabling the AllowTSConnections property which allows or denies new Remote Desktop Services connections.

ValueMeaning
0

Disables the property.

1

Enables the property.

 

ModifyFirewallException [in]

Enables or disables the firewall exception for Remote Desktop.

Windows Server 2008 and Windows Vista with SP1:  This parameter is supported.
Windows Vista, Windows Server 2003, Windows XP, and Windows 2000:  This parameter is not supported.
ValueMeaning
0

Disables the firewall exception for Remote Desktop.

1

Enables the firewall exception for Remote Desktop.

 

Return Value

Returns Success on success; otherwise, returns a WMI error code. Refer to Remote Desktop Services WMI Provider Error Codes for a list of these values. The method returns an error if the setting is under group policy control.

Remarks

Managed Object Format (MOF) files contain the definitions for Windows Management Instrumentation (WMI) classes. MOF files are not installed as part of the Windows SDK. They are installed on the server when you add the associated role by using the Server Manager. For more information about MOF files, see Managed Object Format (MOF).

Requirements

Minimum supported clientWindows XP
Minimum supported serverWindows Server 2003
MOFTscfgwmi.mof
DLLTscfgwmi.dll
Namespace\root\CIMV2\TerminalServices on Windows Vista and Windows Server 2008\root\CIMV2 on Windows XP and Windows Server 2003

See Also

Win32_TerminalServiceSetting

Send comments about this topic to Microsoft

Build date: 10/19/2009

Tags :


Community Content

Thomas Lee
SetAllowTSConnections Method sample using PowerShell
# set-TSConnections.ps1
# Displays then ensures the firewall is configured to allow connections to the TS
# thomas lee - tfl@psp.co.uk
 
# first, get the TS Setting object
$ts=get-WMIObject Win32_TerminalServiceSetting -Namespace ROOT\CIMV2\TerminalServices
 
# now display whether firewall allows connections
 
if ($ts.AllowTSConnections -eq 1)  {
"Connections on server {0} are allowed through the firewall" -f $ts.servername
}
 
# If not - make it so
else {
"Connections on server {0} was not allowed" -f $ts.servername
$r = $ts.SetAllowTSConnections(1)
if ($r.returnvalue -eq 0) {"Connections re-enabled through the firewall"}
else {"*** Firewall could not be recinfigred: error code{0} ***" -f $r.returnvalue}
}

This script when run on a Server 2008 system with TS connetions disabled produced the following output:

  
    
      

PS C:\foo> .\SET-TSCONNECTINS.PS1

Connections on server DC1 was not allowed
Connections re-enabled through the firewal
 

Running the script again directly afterwards produced this output:

PS C:\foo> .\SET-TSCONNECTINS.PS1
Connections on server DC1 are allowed through the firewall
PS C:\foo>

Page view tracker