Windows Vista Forums

Modify Terminal Services Settings
  1. #1


    MiKL Guest

    Modify Terminal Services Settings

    Hello,

    I would like to change the values of any properties from TS
    (TimeLimitPolicy, DisconnectedSessionLimit, ActiveSessionLimit,
    IdleSessionLimit...)



    I wrote:

    -----------------------
    #$ts = Get-WmiObject -class "Win32_TSSessionSetting" -namespace "root\CIMV2"
    |Select-Object -Property *
    foreach ($objItem in $ts) {
    $objItem.TimeLimitPolicy = 1
    $objItem.DisconnectedSessionLimit = 1800000
    $objItem.ActiveSessionLimit = 0
    $objItem.IdleSessionLimit = 1800000
    }
    -----------------
    The values are not commited.
    The method Put() is not avalaible.

    I tried with vbscript and it's ok

    -----------------
    Const PER_USER = 0
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_TSSessionSetting")
    For Each objItem in colItems
    objItem.TimeLimitPolicy = PER_USER
    objItem.Put_
    Next
    ----------------------
    Thanks

    MiKL

      My System SpecsSystem Spec

  2. #2


    CommandBreak Guest

    RE: Modify Terminal Services Settings

    try changing your first line

    $ts = Get-WmiObject -class "Win32_TSSessionSetting" -namespace "root\CIMV2"

    Put() is a script method that you don't have access to with your filter.

    I assume the 'Select-Object -Property *' is preventing the $ts object from
    inheriting the scriptmethod's

    anyone else got any details?


    --
    blog: http://www.commandbreak.com


    "MiKL" wrote:

    > Hello,
    >
    > I would like to change the values of any properties from TS
    > (TimeLimitPolicy, DisconnectedSessionLimit, ActiveSessionLimit,
    > IdleSessionLimit...)
    >
    > I wrote:
    >
    > -----------------------
    > #$ts = Get-WmiObject -class "Win32_TSSessionSetting" -namespace "root\CIMV2"
    > |Select-Object -Property *
    > foreach ($objItem in $ts) {
    > $objItem.TimeLimitPolicy = 1
    > $objItem.DisconnectedSessionLimit = 1800000
    > $objItem.ActiveSessionLimit = 0
    > $objItem.IdleSessionLimit = 1800000
    > }
    > -----------------
    > The values are not commited.
    > The method Put() is not avalaible.
    >
    > I tried with vbscript and it's ok
    >
    > -----------------
    > Const PER_USER = 0
    > strComputer = "."
    > Set objWMIService = GetObject("winmgmts:" _
    > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    > Set colItems = objWMIService.ExecQuery("Select * from Win32_TSSessionSetting")
    > For Each objItem in colItems
    > objItem.TimeLimitPolicy = PER_USER
    > objItem.Put_
    > Next
    > ----------------------
    > Thanks
    >
    > MiKL

      My System SpecsSystem Spec

  3. #3


    MiKL Guest

    RE: Modify Terminal Services Settings

    Thanks, it's ok. Without the select...

    $ts = Get-WmiObject -class "Win32_TSSessionSetting" -namespace "root\CIMV2"
    -computername swpxy085
    $ts.TimeLimitPolicy = 0 |Out-Null
    $ts.Put() |Out-Null
    $ts.TimeLimit("DisconnectedSessionLimit", 1800000) |Out-Null
    $ts.TimeLimit("ActiveSessionLimit", 0) |Out-Null
    $ts.TimeLimit("IdleSessionLimit", 1800000) |Out-Null


    --
    MiKL



    "CommandBreak" wrote:

    > try changing your first line
    >
    > $ts = Get-WmiObject -class "Win32_TSSessionSetting" -namespace "root\CIMV2"
    >
    > Put() is a script method that you don't have access to with your filter.
    >
    > I assume the 'Select-Object -Property *' is preventing the $ts object from
    > inheriting the scriptmethod's
    >
    > anyone else got any details?
    >
    >
    > --
    > blog: http://www.commandbreak.com
    >
    >
    > "MiKL" wrote:
    >

    > > Hello,
    > >
    > > I would like to change the values of any properties from TS
    > > (TimeLimitPolicy, DisconnectedSessionLimit, ActiveSessionLimit,
    > > IdleSessionLimit...)
    > >
    > > I wrote:
    > >
    > > -----------------------
    > > #$ts = Get-WmiObject -class "Win32_TSSessionSetting" -namespace "root\CIMV2"
    > > |Select-Object -Property *
    > > foreach ($objItem in $ts) {
    > > $objItem.TimeLimitPolicy = 1
    > > $objItem.DisconnectedSessionLimit = 1800000
    > > $objItem.ActiveSessionLimit = 0
    > > $objItem.IdleSessionLimit = 1800000
    > > }
    > > -----------------
    > > The values are not commited.
    > > The method Put() is not avalaible.
    > >
    > > I tried with vbscript and it's ok
    > >
    > > -----------------
    > > Const PER_USER = 0
    > > strComputer = "."
    > > Set objWMIService = GetObject("winmgmts:" _
    > > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    > > Set colItems = objWMIService.ExecQuery("Select * from Win32_TSSessionSetting")
    > > For Each objItem in colItems
    > > objItem.TimeLimitPolicy = PER_USER
    > > objItem.Put_
    > > Next
    > > ----------------------
    > > Thanks
    > >
    > > MiKL

      My System SpecsSystem Spec

  4. #4


    Hans Dingemans Guest

    Re: Modify Terminal Services Settings

    Also: note that some wmi classes require the new -authentication parameter
    of the gwmi cmdlet in PowerShell v2.0. I tried to enable remote desktop the
    other day on a machine in the network using PS 1.0 and got an access denied
    error (or something similar). That was my first hands-on experience with
    2.0. Scipt below did the job :-)

    $cred = get-credential
    $ts = gwmi win32_terminalservicesetting -Namespace
    "root\CIMV2\TerminalServices" -Credential $cred -Authentication
    6 -ComputerName "192.168.35.16"
    $ts.SetAllowTSConnections($true)

    See also:
    http://www.microsoft.com/technet/scr...sh/wmiin2.mspx

    Regards,
    Hans

    "MiKL" <MiKL@xxxxxx> wrote in message
    news:2E135C78-5EC0-4F89-9890-FCACBEE2E574@xxxxxx

    > Thanks, it's ok. Without the select...
    >
    > $ts = Get-WmiObject -class "Win32_TSSessionSetting" -namespace
    > "root\CIMV2"
    > -computername swpxy085
    > $ts.TimeLimitPolicy = 0 |Out-Null
    > $ts.Put() |Out-Null
    > $ts.TimeLimit("DisconnectedSessionLimit", 1800000) |Out-Null
    > $ts.TimeLimit("ActiveSessionLimit", 0) |Out-Null
    > $ts.TimeLimit("IdleSessionLimit", 1800000) |Out-Null
    >
    >
    > --
    > MiKL
    >
    >
    >
    > "CommandBreak" wrote:
    >

    >> try changing your first line
    >>
    >> $ts = Get-WmiObject -class "Win32_TSSessionSetting" -namespace
    >> "root\CIMV2"
    >>
    >> Put() is a script method that you don't have access to with your filter.
    >>
    >> I assume the 'Select-Object -Property *' is preventing the $ts object
    >> from
    >> inheriting the scriptmethod's
    >>
    >> anyone else got any details?
    >>
    >>
    >> --
    >> blog: http://www.commandbreak.com
    >>
    >>
    >> "MiKL" wrote:
    >>

    >> > Hello,
    >> >
    >> > I would like to change the values of any properties from TS
    >> > (TimeLimitPolicy, DisconnectedSessionLimit, ActiveSessionLimit,
    >> > IdleSessionLimit...)
    >> >
    >> > I wrote:
    >> >
    >> > -----------------------
    >> > #$ts = Get-WmiObject -class "Win32_TSSessionSetting" -namespace
    >> > "root\CIMV2"
    >> > |Select-Object -Property *
    >> > foreach ($objItem in $ts) {
    >> > $objItem.TimeLimitPolicy = 1
    >> > $objItem.DisconnectedSessionLimit = 1800000
    >> > $objItem.ActiveSessionLimit = 0
    >> > $objItem.IdleSessionLimit = 1800000
    >> > }
    >> > -----------------
    >> > The values are not commited.
    >> > The method Put() is not avalaible.
    >> >
    >> > I tried with vbscript and it's ok
    >> >
    >> > -----------------
    >> > Const PER_USER = 0
    >> > strComputer = "."
    >> > Set objWMIService = GetObject("winmgmts:" _
    >> > & "{impersonationLevel=impersonate}!\\" & strComputer &
    >> > "\root\cimv2")
    >> > Set colItems = objWMIService.ExecQuery("Select * from
    >> > Win32_TSSessionSetting")
    >> > For Each objItem in colItems
    >> > objItem.TimeLimitPolicy = PER_USER
    >> > objItem.Put_
    >> > Next
    >> > ----------------------
    >> > Thanks
    >> >
    >> > MiKL

      My System SpecsSystem Spec

Modify Terminal Services Settings problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
SBS 2008 + terminal services. Stroller SBS Server 10 22 Apr 2010
Terminal Services on HyperV Michael Virtual Server 1 20 Apr 2010
Allow Log In Terminal Services Debbie r .NET General 0 09 Feb 2009
Terminal Services jcpierce Vista General 0 03 Mar 2008
Terminal Services and Ink JT Avalon 0 07 May 2007