Helpforsure

Microsoft Windows Experts

Set Relative Weight in a Terminal Services Session Directory/Broker based Farm via WMI January 25, 2011


Script to set a Relative weight value of 100 in a Terminal Services Session Directory/Broker based Farm via a Script:

=========================

Set Relative Weight to a TS Farm

=========================
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\CIMV2\TerminalServices”)
‘ Obtain an instance of the the class
‘ using a key property value.
Set objShare = objWMIService.Get(“Win32_TSSessionDirectory”)

‘ Obtain an InParameters object specific
‘ to the method.
Set objInParam = objShare.Methods_(“SetServerWeight”). _
inParameters.SpawnInstance_()

‘ Add the input parameters.
objInParam.Properties_.Item(“ServerWeightValue”) =  100

‘ Execute the method and obtain the return status.
‘ The OutParameters object in objOutParams
‘ is created by the provider.
Set objOutParams = objWMIService.ExecMethod(“Win32_TSSessionDirectory”, “SetServerWeight”, objInParam)

‘ List OutParams
Wscript.Echo “Out Parameters: ”
Wscript.echo “ReturnValue: ” & objOutParams.ReturnValue

Advertisements
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s