-
Notifications
You must be signed in to change notification settings - Fork 1
/
get all images.ps1
75 lines (57 loc) · 5.28 KB
/
get all images.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#----------------------------------------------
# Name: export_all_disk_images
# Version: 1.0.0.0
# Start date: 26.06.2014
# Release date: 27.06.2014 alpha
# Description:
#
# Author: George Dicu
# Department: Cloud, Backup
#----------------------------------------------
cd\
$nbpath = "C:\Program Files\Veritas\NetBackup\bin\admincmd"
if (Test-Path $nbpath) {
$info = @()
cd $nbpath
write-output "Provide full path of .csv file exported by export_all_clients script"
$path = read-host
#importing a csv file of all clients from NB generated by export_all_clients
$allclientsinfo = Import-Csv -Path $path
$activeclients = $allclientsinfo | select -uniq Client,PolicyStatus | where {$_.PolicyStatus -eq "Active"}
write-output "Chose Date, eg. mm/dd/yyyy hh:mm:ss, specifies a start date and time for the listing.
The resulting list shows only images in back ups or archives that occurred at or after the specified date and time."
$d = read-host
$startdate = if($d -match "\d*/\d*/\d{4}"){ $d }else{""}
$e = read-host
$enddate = if($e -match "\d*/\d*/\d{4}"){ $e }else{""}
$mtxtkb = ""
$dtxtkb = ""
$i = 1
#selecting uniq active clients
[int]$tc = ($allclientsinfo | select -uniq Client,PolicyStatus | where {$_.PolicyStatus -eq "Active"}).Count
write-output "Iterating through $tc clients, estimated time: " ($tc*2/60) " minutes"
#saveing data from all clinets
foreach($clientsinfo in $activeclients){
#saving the clinet name to a string from an array
$client = $clientsinfo | select -ExpandProperty Client
write-output "$i Getting info from client $client"
$imagesondisk = .\bpimagelist -L -client $client -d $startdate -e $enddate -option INCLUDE_TIR
$imagesonmedia = .\bpimmedia.exe -U -client $client -d $startdate -e $enddate -tape
#selecting and saveing just the KB info
$tkb = $imagesondisk -match "Kilobytes:"
$mtkb = $imagesonmedia -match "Fragment size"
#splitting the KB line and selecting just the size(digits)
foreach($kb in $tkb){
$dtxtkb += ($kb.split(":")[-1].trim()) + "`r`n"
}
foreach($mkb in $mtkb){
$mtxtkb += ($mkb.split(":")[-1].trim()) + "`r`n"
}
$i++
}
$mtxtkb | Out-File C:\temp\powershell\imagesonmedia.txt
$dtxtkb | Out-File C:\temp\powershell\imagesondisk.txt
}
else {
write-host "This script can only run on Netbackup Windows Servers"
}