RSS

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

08 Apr

http://forums.citrix.com/thread.jspa?threadID=241983&tstart=0
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.Initialize(1)

#$farm = New-Object -com "MetaframeCOM.MetaframeFarm"
#$farm.Initialize(1)
$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 = "fake.com"
$smtpClient = New-Object net.Mail.SmtpClient
$smtpClient.Host =
$smtpserver

$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"
$smtpClient.Send($msg)
}

$a_zdc="zdc1","zdc2"

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"
Send-SMTPMail
}

Advertisements
 
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:

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

 
%d bloggers like this: