-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththereisnobackup.ps1
54 lines (34 loc) · 2.16 KB
/
thereisnobackup.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Start HTML Output file style
$style = "<style>"
$style = $style + "Body{background-color:white;font-family:Arial;font-size:10pt;}"
$style = $style + "Table{border-width: 1px; border-style: solid; border-color: black; border-collapse: collapse;}"
$style = $style + "TH{border-width: 1px; padding: 2px; border-style: solid; border-color: black; background-color: #cccccc;}"
$style = $style + "TD{border-width: 1px; padding: 5px; border-style: solid; border-color: black; background-color: white;}"
$style = $style + "</style>"
# End HTML Output file style
$array=@()
$count=0
[System.Collections.ArrayList]$array2=@()
Connect-VIServer -server vcenteriporfqdn -user administrator@vsphere.local -pass parola bilgisi #vcenter bağlantısı
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false #vcenter ssl hatasinin görmezden gelinmesi
$vmos=(Get-VM).Name #vcenter üzerinde çalışan sanal makine bilgileri
Connect-VBRServer -Server localhost
$policys =(Get-VBRJob | select Name).name
foreach ($backup in $policys) {
$array += ($backup | Get-VBRJobObject).name
} #jobların içerisinde bulunan sanal makinelerin $array değişkeni içerisine tek tek kayıt edilmesi
Disconnect-VBRServer # veeam üzerinden disconnect olunması
foreach ($temp in $vmos) {
if(!($array.Contains($temp))) {
$count++ # eşleşmiyorsa +1 count değerinin artırılması
$array2 += $temp #eşleşmeyen makine isminin $array3e eklenmesi
}
}
$dontshow= Import-Csv C:\Scripts\nobackupinfo.txt -Header DontShow
foreach($temp in $dontshow) { #zerto.csv icerisinde belirtilen makineleri array2 icerisine ekleyerek farklarin kontrol edilgidi fonksiyon icerisine bu makineler veeam uzerindeymis gibi gosterir
$array2.Remove($temp.DontShow)
}
$array2 | Out-File C:\Scripts\thereisnovmbackup.csv
$nobackup = Import-Csv "C:\Scripts\thereisnovmbackup.csv" -Header Name
$nobackup | ConvertTo-Html -Head $style Name | Out-File C:\Scripts\Ahey.html
Send-MailMessage -From "Veeam <ankveeam@xx.com>" -To "Onur Babur <onur.babur@xx.com>" -Subject "No Backup Systems" -SmtpServer xx -Port 25 -Body (Get-Content C:\Scripts\Ahey.html | Out-String) -BodyAsHtml