-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexport_clients_nb_version.ps1
84 lines (65 loc) · 5.43 KB
/
export_clients_nb_version.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
76
77
78
79
80
81
82
83
84
#----------------------------------------------
# Name: get_cliets_nb_version
# Version: 1.0.0.0
# Start date: 03.04.2014
# Release date: .04.2014
# Description:
#
# Author: George Dicu
# Department: Cloud
#----------------------------------------------
cd\
$nbpath = "C:\Program Files\Veritas\NetBackup\bin\admincmd"
if (Test-Path $nbpath) {
cd $nbpath
$ErrorActionPreference = "silentlycontinue"
$ResultNBVersion = @()
#export path
Write-Host "Chose full path for exporting csv file"
$exportpath = Read-Host
#reading csv file
Write-Host "Provide full path of csv file generated by export_all_clients.ps1"
$csvpath = Read-Host
#saving just active clients
$activeclients = Import-Csv -Path $csvpath | ? {$_.PolicyStatus -eq "Active"}
#show how many clients are active
write-host "Total of "$activeclients.Length" active clients"
$i = 0
foreach ($activeclient in $activeclients){
$PropertyHash = @{}
$client = $activeclient | select -ExpandProperty Client
$policy = $activeclient | select -ExpandProperty Policy
$getcfg = .\bpgetconfig -s $client
Write-Host "$i. crawling after client: $client from policy $policy"
if ($getcfg -eq $null) {
$PropertyHash += @{
"Client" = $client
"OS" = $activeclient | select -ExpandProperty OS
"Hardware" = $activeclient | select -ExpandProperty Hardware
"Policy" = $policy
"PolicyStatus" = $activeclient | select -ExpandProperty PolicyStatus
"NB Location" = "-"
"NBVersion" = "client hostname could not be found"
}
}
else {
$PropertyHash += @{
"Client" = $client
"NBOS" = $activeclient | select -ExpandProperty OS
"OS" = $getcfg[-1]
"Hardware" = $activeclient | select -ExpandProperty Hardware
"Policy" = $policy
"PolicyStatus" = $activeclient | select -ExpandProperty PolicyStatus
"NB Location" = $getcfg[-2]
"NBVersion" = $getcfg[2]
}
}
$i++
$ResultNBVersion += New-Object -TypeName PSObject -Property $PropertyHash
}
Write-Host "Done!!"
$ResultNBVersion | Export-Csv -Path "$exportpath" -NoTypeInformation
}
else {
write-host "This script can only run on Netbackup Windows Servers"
}