Server 2012 de Cluster Aware Update (CAU) ile Cluster’a üye Host’ların Windows Update’lerini otomatik olarak yaptırabiliyoruz.
Burada ise değineceğimiz konu şu;
Birçok lokasyonu olan ve her lokasyonda bir ya da birkaç Hyper-V Cluster’ı bulunan bir ortamda olduğunuzu düşünün. CAU ile tek tek tüm Cluster’lara bağlanıp CAU Status’unu kontrol etmek hem çok zaman alacak hem de çok yorucu bir çalışma olacaktır. Bu durumda bir Powershell Script ile belirli bir zaman aralığında tüm Cluster’larınızın CAU Status’unu görebilir bunu kendinize bir .txt file olarak mail attırabilirsiniz.
1. Script
# Microsoft Windows Server 2012 Hyperv&FailOver Cluster CAU Update Status Script # Osman Bagislanan param ( ) Write-Host "" Write-Host "###################################################################" -ForegroundColor Green Write-Host "" Write-Host "" Write-Host "Microsoft Windows Server 2012 Hyperv&FailOver Cluster CAU Update Status Script" -ForegroundColor Green Write-Host "" Write-Host "" Write-Host "Osman Bagislanan 2016" -ForegroundColor Yellow Write-Host "" Write-Host "" Write-Host "###################################################################" -ForegroundColor Green Write-Host "" Start-Sleep -Seconds 0 Get-CauReport -ClusterName ADANA-CLS1HV -StartDate 01/02/2016 -EndDate 25/02/2016 Get-CauReport -ClusterName ANTALYA-CLS1HV -StartDate 01/02/2016 -EndDate 25/02/2016 Get-CauReport -ClusterName ANKARA-CLS1HV -StartDate 01/02/2016 -EndDate 25/02/2016 Get-CauReport -ClusterName ARTVIN-CLS1HV -StartDate 01/02/2016 -EndDate 25/02/2016 Get-CauReport -ClusterName BURSA-CLS1HV -StartDate 01/02/2016 -EndDate 25/02/2016 Get-CauReport -ClusterName BOLU-CLS1HV -StartDate 01/02/2016 -EndDate 25/02/2016 Get-CauReport -ClusterName BAYBURT-CLS1HV -StartDate 01/02/2016 -EndDate 25/02/2016 Get-CauReport -ClusterName DENIZLI-CLS1HV -StartDate 01/02/2016 -EndDate 25/02/2016 Get-CauReport -ClusterName ELAZIG-CLS1HV -StartDate 01/02/2016 -EndDate 25/02/2016 Get-CauReport -ClusterName ESKISEHIR-CLS1HV -StartDate 01/02/2016 -EndDate 25/02/2016 Get-CauReport -ClusterName GIRESUN-CLS1HV -StartDate 01/02/2016 -EndDate 25/02/2016 Get-CauReport -ClusterName IZMIR-CLS1HV -StartDate 01/02/2016 -EndDate 25/02/2016 Get-CauReport -ClusterName ISTANBUL-CLS1HV -StartDate 01/02/2016 -EndDate 25/02/2016
Bu script clusterlarınızın CAU statuslarınız listeler.
2.Script
# Microsoft Windows Server 2012 Hyperv&FailOver Cluster CAU Update Status Script # Osman Bagislanan param ( ) Write-Host "" Write-Host "###################################################################" -ForegroundColor Green Write-Host "" Write-Host "" Write-Host "Microsoft Windows Server 2012 Hyperv&FailOver Cluster CAU Update Status Script" -ForegroundColor Green Write-Host "" Write-Host "" Write-Host "Osman Bagislanan 2016" -ForegroundColor Yellow Write-Host "" Write-Host "" Write-Host "###################################################################" -ForegroundColor Green Write-Host "" Start-Sleep -Seconds 0 #Tum Stadlar CAU Status $A = C:\Script\CAUControlScript\CAUStatus.ps1| out-file -Filepath C:\Script\CAUControlScript\CAUStatusScriptLogs.txt ############################################################################################################################## $emailFrom = "CAUStatus@yourdomain.com" $emailTo = "yourname@yourdomain.com" $subject = "CAUStatus" $body = "$A" $smtpServer = "your smtp server adressl" $filePath = "C:\Script\CAUControlScript\CAUStatusScriptLogs.txt" Function sendEmail([string]$emailFrom, [string]$emailTo, [string]$subject,[string]$body,[string]$smtpServer,[string]$filePath) { #initate message $email = New-Object System.Net.Mail.MailMessage $email.From = $emailFrom $email.To.Add($emailTo) $email.Subject = $subject $email.Body = $Body # initiate email attachment $emailAttach = New-Object System.Net.Mail.Attachment $filePath $email.Attachments.Add($emailAttach) #initiate sending email $smtp = new-object Net.Mail.SmtpClient($smtpServer) $smtp.Send($email) } #Call Function sendEmail $emailFrom $emailTo $subject $body $smtpServer $filePath #############################################################################################################################
Bu script ise sunu yapar. Önce birinci scripti çalıstırıp CAU statusuna bakar sonra aldıgı çıktıyı bir txt ye yazıp size mail atar.
Böylece tek bir noktadan tüm Cluster’larınızın CAU Status’unu görebilirsiniz.
Bu konuyla ilgili sorularınızı alt kısımda bulunan yorumlar alanını kullanarak sorabilirsiniz.
Referanslar