-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexport_all_clients.ps1
59 lines (43 loc) · 3.75 KB
/
export_all_clients.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
#----------------------------------------------
# Name: export_all_clients
# Version: 1.0.0.0
# Start date: 04.04.2014
# Release date: 04.04.2014
# Description:
#
# Author: George Dicu
# Department: Cloud, Backup
#----------------------------------------------
cd\
$nbpath = "C:\Program Files\Veritas\NetBackup\bin\admincmd"
if (Test-Path $nbpath) {
cd $nbpath
write-host "Provide full path of .csv file exported by export_all_policies script"
$path = read-host
$allpoliciesinfo = Import-Csv -Path $path
Write-Host "chose full-path where to save the csv file"
$path = Read-Host
$ClientsResult = @()
$policyinfo = @()
foreach ($policyinfo in $allpoliciesinfo ){
$policy = $policyinfo | select -ExpandProperty PolicyName
Write-Host "crawling after policy $policy"
$clients = .\bpplclients $policy
for($i=2;$i -le ($clients.Length)-1;$i++){
$PropertyHash = @{}
$PropertyHash += @{
"Client" = ($clients[$i] -replace "\s+",";").split(";")[2]
"OS" = ($clients[$i] -replace "\s+",";").split(";")[1]
"Hardware" = ($clients[$i] -replace "\s+",";").split(";")[0]
"Policy" = $policyinfo | select -ExpandProperty PolicyName
"PolicyStatus" = $policyinfo | select -ExpandProperty Active
#@{$true="Active";$false="Inactive"}[($policyinfo | select -ExpandProperty Active) -eq "yes"]
}
$ClientsResult += New-Object -TypeName PSObject -Property $PropertyHash
}
}
$ClientsResult | Export-Csv -Path "$path" -NoTypeInformation
}
else {
write-host "This script can only run on Netbackup Windows Servers"
}