#Ctx_Function ver1.01 #Ctx_Function ver1.02 #25/05/2011 # Adding Count for Function Event4033 # Add "CitrixTools Sessions Cleaner" service in TestingService function #Ctx_Function ver1.03 #07/06/2011 # Adding Count for every section Function Get-CustomHTML ($Header) { $XenAppReport = @" XenApp_Check ($($Header)) $($Header)
XenApp_Check $Version generated on $($ENV:Computername)
Report created on $(Get-Date -format g)
"@ Return $XenAppReport } Function Get-CustomHeader0 ($Title) { $XenAppReport = @"

$($Title)

"@ Return $XenAppReport } Function Get-CustomHeader ($Title, $cmnt) { $XenAppReport = @"

$($Title)

"@ Return $XenAppReport } Function Get-CustomHeaderClose { $XenAppReport = @"
"@ Return $XenAppReport } Function Get-CustomHeader0Close { $XenAppReport = @"
"@ Return $XenAppReport } Function Get-CustomHTMLClose { $XenAppReport = @" "@ Return $XenAppReport } Function Get-HTMLTable { param([array]$Content) $HTMLTable = $Content | ConvertTo-Html $HTMLTable = $HTMLTable -replace '', "" $HTMLTable = $HTMLTable -replace '', "" $HTMLTable = $HTMLTable -replace '', "" $HTMLTable = $HTMLTable -replace '', "" $HTMLTable = $HTMLTable -replace '', "" $HTMLTable = $HTMLTable -replace '', '
' $HTMLTable = $HTMLTable -replace '', "" $HTMLTable = $HTMLTable -replace '', "" $HTMLTable = $HTMLTable -replace '
', "" Return $HTMLTable } Function Get-HTMLDetail ($Heading, $Detail) { $XenAppReport = @"
$Heading $($Detail)
"@ Return $XenAppReport } Function TestingService { [HashTable] $OutputEnteteServ = @{} $Services_XenApp = ("IMAService","citrix SMA service","MFCom","CtxHttp","cpsvc","CitrixXTEServer","CdmService","CtxActiveSync","CdfSvc","IMAAdvanceSrv","Service de cryptage Citrix","spooler") Foreach ($Services_XenApp in $Services_XenApp) { $Svc = [System.ServiceProcess.ServiceController]::GetServices($Servers) | where{$_.name -eq $Services_XenApp} if($Svc.status -eq "Stopped") { $OutputEnteteServ.TestingServiceTab += @($Servers | Select @{N="Servers Name";E={$Servers.ServerName}}, @{N="Service Stopped";E={$Svc.name}} ) $OutputEnteteServ.TestingServiceCount += 1 } } Return $OutputEnteteServ } Function DiskSpace { [hashtable] $OutputServDisk = @{} $drives = Get-WmiObject -ComputerName $servers Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3} foreach($drive in $drives) { if (($drive.FreeSpace/1GB) -lt $DiskMin) { $OutputServDisk.DiskSpaceTab += @($Servers | Select @{N="Servers Name";E={$Servers.ServerName}}, @{N="Drive";E={($drive.DeviceID)}}, @{N="Free space";E={($drive.FreeSpace/1GB).ToString("0.00")}}, @{N="Total space";E={($drive.size/1GB).ToString("0.00")}} ) $OutputServDisk.DiskSpaceCount += 1 } } Return $OutputServDisk } Function LogonDisabled { [hashtable] $OuTputServLogon = @{} if($Servers.LogOnsEnabled -match "False") { $OuTputServLogon.LogonDisabledTab += @($Servers | Select @{N="Servers Name";E={$Servers.ServerName}}, @{N="Logon Disabled";E={"TRUE"}} ) $OuTputServLogon.LogonDisabledCount += 1 } Return $OuTputServLogon } Function Send-SMTPmail($to, $from, $subject, $smtpserver, $body) { $mailer = new-object Net.Mail.SMTPclient($smtpserver) $msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body) $msg.IsBodyHTML = $true $mailer.send($msg) } Function Event4033 { [hashtable] $OutputEnteteEvent4033 = @{} $Event4003 = (Get-Eventlog system -computer $Servers -Newest 500 | where {$_.EventID -eq 4033}| Where-Object {($_.TimeWritten).Date -eq (Get-Date).Date}) if($Event4003 -eq $NULL) {} else { Foreach ($line in $Event4003) { $OutputEnteteEvent4033.Event4033Tab += @($Servers | Select @{N="Servers Name";E={$Servers.ServerName}}, @{N="Time Generated";E={$line.TimeWritten}}, @{N="Source";E={$line.MEssage}} ) $OutputEnteteEvent4033.Event4033Count += 1 } } Return $OutputEnteteEvent4033 } Function LoadMaintenance { [Hashtable] $OuTputLoadMaintenance = @{} $LoadEvalMaint = get-xaloadevaluator -servername $Servers if ($LoadEvalMaint.LoadEvaluatorName -eq $LoadEval_Check) { $OuTputLoadMaintenance.LoadMaintenanceTab += @($Servers | Select @{N="Servers Name";E={$Servers.ServerName}}, @{N="Load Evaluator Name";E={$LoadEvalMaint.LoadEvaluatorName}} ) $OuTputLoadMaintenance.LoadMaintenanceCount += 1 } Return $OutputLoadMaintenance } Function App_CountServers { [hashtable] $OuTputApp_Servers = @{} if (($Applications.servernames).count -le "1") { $OuTputApp_Servers.App_CountServersTab += @($Applications | Select @{N="Application";E={$Applications}}, @{N="Folder Path";E={$Applications.FolderPath}}, @{N="Number Server";E={($Applications.servernames).count}}, @{N="Server Name";E={$Applications.servernames}} ) $OuTputApp_Servers.App_CountServersCount += 1 } Return $OuTputApp_Servers } Function App_Disable { [hashtable] $OuTputApp_Disable = @{} if ($Applications.enabled -eq $False) { $OuTputApp_Disable.App_DisableTab += @($Applications | Select @{N="Application";E={$Applications}}, @{N="Folder Path";E={$Applications.FolderPath}}, @{N="Application Enable";E={$Applications.Enabled}} ) $OuTputApp_Disable.App_DisableCount += 1 } Return $OuTputApp_Disable } Function PolicyDisable { [hashtable] $OutputEntetePolicyDisable = @{} if ($Policy.Enabled -eq $False) { $OutputEntetePolicyDisable.PolicyDisableTab += @($Policy | Select @{N="Policy Name";E={$policy.PolicyName}}, @{N="Policy enable";E={$Policy.Enabled}} ) $OutputEntetePolicyDisable.PolicyDisableCount += 1 } Return $OutputEntetePolicyDisable } function GetElapsedTime() { [hashtable] $TimeToBuild = @{} $TimeToBuild.runtime = $(get-date) - $scriptStartTime $TimeToBuild.retStr = [string]::format("{0}:{1}:{2}", ` $TimeToBuild.runtime.Hours, ` $TimeToBuild.runtime.Minutes, ` $TimeToBuild.runtime.Seconds) Return $TimeToBuild } Function Uptime () { [hashtable] $OutputUptime = @{} $lastboottime = (Get-WmiObject -Class Win32_OperatingSystem -computername $Servers).LastBootUpTime $sysuptime = (Get-Date) [System.Management.ManagementDateTimeconverter]::ToDateTime($lastboottime) if ($sysuptime.days -ge 30) { $OutputUptime.UptimeTab += @($Servers | Select @{N="Server Name";E={$Servers.ServerName}}, @{N="Uptime (in days)";E={($sysuptime.days)}}) $OutputUptime.UptimeCount += 1 #Write-Host "$Servers has been up for: " $sysuptime.days "days" $sysuptime.hours "hours" $sysuptime.minutes "minutes" $sysuptime.seconds "seconds" } Return $OutputUptime }