Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. $Script_Name = "Current_Shadow_Copy_Provision"
  2. $Version = 2.2
  3.  
  4.  
  5. cls
  6. write-host "Script $Script_Name Version $version`n"
  7.  
  8. $total = 0
  9. $Totalsnap = 0
  10. $VSSAdmin = Vssadmin List shadows
  11. Write-host "Found" ($Vssadmin | select-string 'Contents of shadow copy set ID').count "snapshots on this server`n"
  12. $ProtectionGroup = @(get-protectiongroup (&hostname))
  13. "Provisioning Protection Group # of Snapshots"
  14. "------------ ------------------------- --------------"
  15. ForEach ($pg in $ProtectionGroup)
  16. {
  17. $CurrentSnap = 0
  18. $Provisioning = 0
  19. $PolicyVolume = 0
  20. $PolicyApp = 0
  21. $VolumeSnaps = @()
  22. $ApplicationSnaps =
  23. $ds = @(Get-DataSource $pg)
  24. $VolumeSnaps = @($ds | ? { $_.type.name -eq 'volume' -or $_.type.name -eq 'Client'} | Sort-Object replicapath | select-object replicapath |get-unique -asstring)
  25. $VolumeDS = $VolumeSnaps.count
  26. $ApplicationSnaps = @($ds | ? { $_.type.name -ne 'volume' -and $_.type.name -ne 'Client'} | Sort-Object replicapath | select-object replicapath |get-unique -asstring)
  27. $ApplicationDS = $ApplicationSnaps.count
  28. $DSTotal = $VolumeSnaps + $ApplicationSnaps
  29. $Policy = (Get-PolicyObjective $pg -ShortTerm).schedules
  30. if ($pg.protectionmethod -like '*disk*')
  31. {
  32. If ($VolumeDS -ne 0 )
  33. {
  34. $PolicyVolume = @(($policy | ? { $_.jobtypestring -eq 'Shadow Copy'}).TimesOfDay).count
  35. }
  36. If ($ApplicationDS -ne 0)
  37. {
  38. $PolicyApp = @(($policy | ? { $_.jobtypestring -eq 'Express full'}).TimesOfDay).count
  39. }
  40. $Provisioning = $volumeDS * $PolicyVolume * $pg.onsiterecoveryrange.key + $ApplicationDS * $PolicyApp * $pg.onsiterecoveryrange.key
  41. ForEach ($DSTotal1 in $DSTotal)
  42. {
  43. $CurrentSnap = $CurrentSnap + ($VSSAdmin | Select-String $Dstotal1.replicapath.substring(4,44)).count
  44. }
  45. }
  46. $TotalSnap = $Totalsnap + $CurrentSnap
  47.  
  48. $output = "{0,12} {1,-25} {2,5}" -f $Provisioning, $pg.friendlyname, $CurrentSnap
  49. if ($color -eq 'White') { $color = 'cyan' } else { $Color = 'white' }
  50. write-host $output -f $color
  51. $Total = $total + $Provisioning
  52.  
  53. }
  54.  
  55. $inactive = 0
  56. $InactiveDS = @()
  57. $InactiveDSTotal = @(get-datasource (&hostname) -inactive)
  58. foreach ($ds in $InactiveDSTotal)
  59. {
  60. If (($InactiveDS | ? { $_.replicapath -eq $ds.replicapath}) -eq $Null)
  61. {
  62. $InactiveDS = $InactiveDS + $ds
  63. }
  64. }
  65.  
  66. $ActiveDS = @(get-datasource (&hostname) | ? { $_.UnderActiveProtectionFromPS -eq $true })
  67. ForEach ($ds in $InactiveDS)
  68. {
  69. if ($ds.iscollocated -eq $true -or $ds.type.name -eq 'volume')
  70. {
  71. $CollocatedProtected = @($ActiveDS | ? { $_.ReplicaPath -eq $ds.ReplicaPath}).count
  72. if ($CollocatedProtected -eq 0)
  73. {
  74. [String]$ReplicaPath = $ds.protectableobjectloadpath.values
  75. $ReplicaPath = $ReplicaPath.Substring($ReplicaPath.IndexOf("vol_"),40)
  76. $inactive = $inactive + ( $VSSAdmin | Select-String -Pattern $ReplicaPath).count
  77. }
  78. }
  79. else
  80. {
  81. [String]$ReplicaPath = $ds.protectableobjectloadpath.values
  82. $ReplicaPath = $ReplicaPath.Substring($ReplicaPath.IndexOf("vol_"),40)
  83. $inactive = $inactive + ( $VSSAdmin | Select-String -Pattern $ReplicaPath).count
  84. #$inactive = $inactive + @(get-recoverypoint $ds | ? { $_.IsIncremental -eq $False }).count
  85. }
  86.  
  87. }
  88. if ($Inactive -gt 0)
  89. {
  90. $output = "{0,12} Inactive Protection {1,5}" -f $Inactive, $Inactive
  91. write-host $output -f magenta
  92. $total = $total + $inactive
  93. $TotalSnap = $TotalSnap + $Inactive
  94. }
  95.  
  96. "------------ ------------------------- --------------"
  97. $output = "{0,12} {1,5} " -f $total, $TotalSnap
  98. write-host $output -f yellow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement