Post from July, 2008

XenApp: Create “Offline” Load Evaluator

Sunday, 27. July 2008 23:00

Administrators of Citrix XenApp (formerly known as: Presentation Server) normally use a Load Evaluator with an empty Schedule Rule to take a server offline for maintenance or troubleshooting purposes. An empty Schedule Rule maximizes the server’s load, thus it won’t accept any new ICA sessions while all active sessions are not affected. Compared to CHANGE LOGON /DISABLE the "Offline Load Evaluator" allows disconnected user’s to reconnect to their sessions, and Administrators are still able to establish new RDP sessions.

The PowerShell script in this article uses MFCOM to create the Load Evaluator and can be used in automated Citrix Farm setups (like Login ConsultantsSolution4 framework)

Creating a new Load Evaluator and attaching a Rule to it is straightforward:

# NAME
#     Add-DisableICALogonLE.ps1
#
# SYNOPSIS
#     Creates a Load Evaluator with an empty Schedule Rule.
#
# SYNTAX
#     .\Add-DisableICALogonLE.ps1 -name Name [-description Description]
#
# DETAILED DESCRIPTION
#     A Load Evaluator with an empty Schedule Rule will maximize a XenApp
#     server's load. Thus, it won't accept new ICA sessions while active
#     and disconnected sessions are not affected.
#
# AUTHOR
#     Frank-Peter Schultze www.fpschultze.de
#
# DATE
#     27-Jul-2008

Param(
	$name = $(throw "Load Evaluator name must be specified"),
	$description = "Takes server offline for maintenance purposes"
)

$MetaFrameWinFarmObject = 1
$LMRuleSchedule = 5

$myfarm = New-Object -ComObject "MetaFrameCOM.MetaFrameFarm"
$myfarm.Initialize($MetaFrameWinFarmObject)
$myfarm.LoadEvaluators | %{if ($_.LEName -eq $name) {
		Write-Warning "The load evaluator `"$name`" already exists."; break
	}
}

Write-Verbose "Creating Load Evaluator `"$name`" . . ."

$newrule = New-Object -ComObject "MetaFrameCOM.MetaFrameLMRule"
$newrule.RuleType = $LMRuleSchedule

$allrules = New-Object -ComObject "MetaFrameCOM.MetaFrameLMRules"
$allrules.AddRule($newrule)

$newle = New-Object -ComObject "MetaFrameCOM.MetaFrameLoadEvaluator"
$newle.LEName = $name
$newle.Description = $description
$newle.Rules = $allrules
$newle.SaveData()

Category:Scripting, Windows PowerShell | Comment (0) | Author: Frank-Peter

How To Improve PowerShell 1.0 Startup Time?

Thursday, 24. July 2008 19:11

According to Speeding Up PowerShell the PSv1 setup doesn’t take "the step that makes things go fast on your machine". The article refers to a ps1 script that fixed this issue.

Category:Scripting, Windows PowerShell | Comment (0) | Author: Frank-Peter

How To Map A Network Printer?

Monday, 14. July 2008 22:35

If you want to add a network printer connection with PowerShell try one of the following ways:

Printui.dll Call

$PrinterPath = "\\machine\printer"
rundll32.exe printui.dll,PrintUIEntry /q /in /n$PrinterPath

Use WshNetwork’s AddWindowsPrinterConnection method

PrinterPath = "\\machine\printer"
(New-Object -ComObject WScript.Network).AddWindowsPrinterConnection($PrinterPath)

Use WMI Win32_Printer’s AddPrinterConnection method

PrinterPath = "\\machine\printer"
([wmiclass]"Win32_Printer").AddPrinterConnection($PrinterPath)

Category:Scripting, Windows PowerShell | Comment (0) | Author: Frank-Peter