-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFrozenMedia.ps1
97 lines (67 loc) · 6 KB
/
FrozenMedia.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
85
86
87
88
89
90
91
92
93
94
95
96
97
$objResult = @()
$date = Get-Date -Format dd/MM/yyyy
$time = Get-Date -Format hh:mm:ss
cd\
cd "C:\Program Files\Veritas\NetBackup\bin\admincmd\"
write-host "Check interval XO200 - XO379"
for($i=200;$i -le 379;$i++){
$rows = .\nbemmcmd.exe -listmedia -mediaid "XO0$i"
$PropertyHash = @{}
$PropertyHash += @{
"Media ID" = (($rows[3] -replace "\s+",";").split(";"))[2]
"Media Barcode" = (($rows[10] -replace "\s+",";").split(";"))[1]
"Status" = (($rows[29] -replace "\s+",";").split(";"))[2]
"Host" = (($rows[12] -replace "\s+",";").split(";"))[3]
}
$objResult += New-Object -TypeName PSObject -Property $PropertyHash
}
write-host "Check interval XO380 - XO409"
for($i=380;$i -le 409;$i++){
$rows = .\nbemmcmd.exe -listmedia -mediaid 0$i"L5"
$PropertyHash = @{}
$PropertyHash += @{
"Media ID" = (($rows[3] -replace "\s+",";").split(";"))[2]
"Media Barcode" = (($rows[10] -replace "\s+",";").split(";"))[1]
"Status" = (($rows[29] -replace "\s+",";").split(";"))[2]
"Host" = (($rows[12] -replace "\s+",";").split(";"))[3]
}
$objResult += New-Object -TypeName PSObject -Property $PropertyHash
}
write-host "Check interval XO410 - XO499"
for($i=410;$i -le 499;$i++){
$rows = .\nbemmcmd.exe -listmedia -mediaid "XO0$i"
$PropertyHash = @{}
$PropertyHash += @{
"Media ID" = (($rows[3] -replace "\s+",";").split(";"))[2]
"Media Barcode" = (($rows[10] -replace "\s+",";").split(";"))[1]
"Status" = (($rows[29] -replace "\s+",";").split(";"))[2]
"Host" = (($rows[12] -replace "\s+",";").split(";"))[3]
}
$objResult += New-Object -TypeName PSObject -Property $PropertyHash
}
write-host "Check interval IBM001 - IBM099"
for($i=1;$i -le 99;$i++){
$rows = .\nbemmcmd.exe -listmedia -mediaid @{$true="IBM00$i";$false="IBM0$i"}[$i -le 9]
$PropertyHash = @{}
$PropertyHash += @{
"Media ID" = (($rows[3] -replace "\s+",";").split(";"))[2]
"Media Barcode" = (($rows[10] -replace "\s+",";").split(";"))[1]
"Status" = (($rows[29] -replace "\s+",";").split(";"))[2]
"Host" = (($rows[12] -replace "\s+",";").split(";"))[3]
}
$objResult += New-Object -TypeName PSObject -Property $PropertyHash
}
$fn = ($objResult | ? {$_.Status -eq "FROZEN"}).Length
$media = $objResult | ? {$_.Status -eq "FROZEN"} | Select-Object -ExpandProperty "Media ID"
$hostcontrol = $objResult | ? {$_.Status -eq "FROZEN"} | Select-Object -ExpandProperty "Host"
#if 0 media are frozen, exit script
if($fn -eq 0){
write-host "zero media frozen."
exit
}
# while we have tapes freezed, one by one, unfreeze them
for($i=0;$i -le ($fn-1);$i++){
Write-Host ($fn-$i)" media to unfreeze"
Write-Host "unfreezing media "$media[$i]" on host control "$hostcontrol[$i]
.\bpmedia -unfreeze -m $media[$i] -h $hostcontrol[$i]
}