Citrix Forums : PowerShell, MFCOM and multiple farms … – Sent using Google Toolbar

08 Apr
this site was my inspiration for writing script to read from 2 separate farms and emailing session counts (code below):

function Send-SMTPMail {
$EmailAddr = "contactme"
$ReportHeaderDate = get-date
$t = [system.type]::GetTypeFromProgID("MetaFrameCOM.MetaFrameFarm", "$zi")
$farm = [system.Activator]::CreateInstance($t)

#$farm = New-Object -com "MetaframeCOM.MetaframeFarm"
$farm.Sessions | Group-Object ServerName | Sort-Object name | Format-Table Name,Count -auto| Out-File fsessions.txt

$filename = "fsessions.txt"

$a = Get-Content $filename

foreach ($i in $a)
{$body = $body + $i + "`n"}

$file = $filename
$smtpServer = ""
$smtpClient = New-Object net.Mail.SmtpClient
$smtpClient.Host =

$msg = New-Object net.Mail.MailMessage
$msg.To.Add($EmailAddr) #Email Addresses separated by commas with no space "add1,add2,add3"
$msg.From = "faker" #must be from same domain as smtp server (duh)
$msg.Subject = "$hdrfarm Farm – Total Sessions – $ReportHeaderDate"
$msg.Body = $body
Write-Host "`n`nSending Email, Please Wait"


foreach ($zi in $a_zdc)
{if ($zi -eq "zdc1"){$hdrfarm="Citrix 4.5"}
elseif ($zi -eq "zdc2"){$hdrfarm="Citrix 4.0"}

Write-Host "`n`nProcessing $zi"

Leave a comment

Posted by on April 8, 2010 in Uncategorized


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: