Posts RSS Comments RSS 253 Posts and 411 Comments till now

Set-CitrixServerLogon.ps1 (Citrix Top 10)

Here is a useful little script. This Creates a MFCom Server Object and disables or Enables Logons for that Server.

# Set-CitrixServerLogon.ps1
# Brandon Shell [MVP]
# www.bsonposh.com
# Sets the Server to Enable or Disable Logons
Param($Server,[switch]$enable,[switch]$disable,[switch]$help)
function HelpMe{
    Write-Host
    Write-Host " Set-CitrixServerLogon.ps1:" -fore Green
    Write-Host "   Sets the Server to Enable or Disable Logons"
    Write-Host
    Write-Host " Parameters:" -fore Green
    Write-Host "   -Server                  : Optional. Server to Set Logon"
    Write-Host "   -Enable                  : Optional. Checks Hours of Idle Time (Default)"
    Write-Host "   -Disable                 : Optional. Checks Minutes of Idle Time"
    Write-Host "   -Help                    : Optional. Displays This"
    Write-Host
    Write-Host " Examples:" -fore Green
    Write-Host "   To disable the Logon for a Server" -fore White
    Write-Host "     Set-CitrixServerLogon.ps1 -server <serverName> -Disable" -fore Yellow
    Write-Host
}

if(!$Server -or $help){helpme;Write-Host;return}

Write-Host

Write-Host " Getting Server [$Server]"
$mfsrv = New-Object -ComObject MetaFrameCOM.MetaFrameServer

Write-Host " – Initializing Server"
$mfsrv.Initialize(6,$Server)

if($enable)
{
    Write-Host " – Setting to EnableLogon = 1"
    $mfSrv.WinServerObject.EnableLogon = 1
}
if($disable)
{
    Write-Host " – Setting to EnableLogon = 0"
    $mfSrv.WinServerObject.EnableLogon = 0
}

Write-Host " – Server [$($mfSrv.ServerName)] is set to [$($mfSrv.WinServerObject.EnableLogon)] for EnableLogon"

Write-Host

Another option would be to remove the Apps from the Server all together.

# Unpublish-CitrixServer.ps1
# Brandon Shell [MVP]
# www.bsonposh.com
# Removes all App from Server
Param($Server)
$mfsrv = New-Object -ComObject MetaFrameCOM.MetaFrameServer
$mfsrv.Initialize(6,$Server.ToUpper())
$mfsrv | foreach{$_.Applications} | foreach{$_.LoadData(1);$_.RemoveServer($Server.ToUpper());$_.SaveData()}

Trackback this post | Feed on Comments to this post

Leave a Reply

You must be logged in to post a comment.