Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $Script_Name = "Current_Shadow_Copy_Provision"
- $Version = 2.2
- cls
- write-host "Script $Script_Name Version $version`n"
- $total = 0
- $Totalsnap = 0
- $VSSAdmin = Vssadmin List shadows
- Write-host "Found" ($Vssadmin | select-string 'Contents of shadow copy set ID').count "snapshots on this server`n"
- $ProtectionGroup = @(get-protectiongroup (&hostname))
- "Provisioning Protection Group # of Snapshots"
- "------------ ------------------------- --------------"
- ForEach ($pg in $ProtectionGroup)
- {
- $CurrentSnap = 0
- $Provisioning = 0
- $PolicyVolume = 0
- $PolicyApp = 0
- $VolumeSnaps = @()
- $ApplicationSnaps =
- $ds = @(Get-DataSource $pg)
- $VolumeSnaps = @($ds | ? { $_.type.name -eq 'volume' -or $_.type.name -eq 'Client'} | Sort-Object replicapath | select-object replicapath |get-unique -asstring)
- $VolumeDS = $VolumeSnaps.count
- $ApplicationSnaps = @($ds | ? { $_.type.name -ne 'volume' -and $_.type.name -ne 'Client'} | Sort-Object replicapath | select-object replicapath |get-unique -asstring)
- $ApplicationDS = $ApplicationSnaps.count
- $DSTotal = $VolumeSnaps + $ApplicationSnaps
- $Policy = (Get-PolicyObjective $pg -ShortTerm).schedules
- if ($pg.protectionmethod -like '*disk*')
- {
- If ($VolumeDS -ne 0 )
- {
- $PolicyVolume = @(($policy | ? { $_.jobtypestring -eq 'Shadow Copy'}).TimesOfDay).count
- }
- If ($ApplicationDS -ne 0)
- {
- $PolicyApp = @(($policy | ? { $_.jobtypestring -eq 'Express full'}).TimesOfDay).count
- }
- $Provisioning = $volumeDS * $PolicyVolume * $pg.onsiterecoveryrange.key + $ApplicationDS * $PolicyApp * $pg.onsiterecoveryrange.key
- ForEach ($DSTotal1 in $DSTotal)
- {
- $CurrentSnap = $CurrentSnap + ($VSSAdmin | Select-String $Dstotal1.replicapath.substring(4,44)).count
- }
- }
- $TotalSnap = $Totalsnap + $CurrentSnap
- $output = "{0,12} {1,-25} {2,5}" -f $Provisioning, $pg.friendlyname, $CurrentSnap
- if ($color -eq 'White') { $color = 'cyan' } else { $Color = 'white' }
- write-host $output -f $color
- $Total = $total + $Provisioning
- }
- $inactive = 0
- $InactiveDS = @()
- $InactiveDSTotal = @(get-datasource (&hostname) -inactive)
- foreach ($ds in $InactiveDSTotal)
- {
- If (($InactiveDS | ? { $_.replicapath -eq $ds.replicapath}) -eq $Null)
- {
- $InactiveDS = $InactiveDS + $ds
- }
- }
- $ActiveDS = @(get-datasource (&hostname) | ? { $_.UnderActiveProtectionFromPS -eq $true })
- ForEach ($ds in $InactiveDS)
- {
- if ($ds.iscollocated -eq $true -or $ds.type.name -eq 'volume')
- {
- $CollocatedProtected = @($ActiveDS | ? { $_.ReplicaPath -eq $ds.ReplicaPath}).count
- if ($CollocatedProtected -eq 0)
- {
- [String]$ReplicaPath = $ds.protectableobjectloadpath.values
- $ReplicaPath = $ReplicaPath.Substring($ReplicaPath.IndexOf("vol_"),40)
- $inactive = $inactive + ( $VSSAdmin | Select-String -Pattern $ReplicaPath).count
- }
- }
- else
- {
- [String]$ReplicaPath = $ds.protectableobjectloadpath.values
- $ReplicaPath = $ReplicaPath.Substring($ReplicaPath.IndexOf("vol_"),40)
- $inactive = $inactive + ( $VSSAdmin | Select-String -Pattern $ReplicaPath).count
- #$inactive = $inactive + @(get-recoverypoint $ds | ? { $_.IsIncremental -eq $False }).count
- }
- }
- if ($Inactive -gt 0)
- {
- $output = "{0,12} Inactive Protection {1,5}" -f $Inactive, $Inactive
- write-host $output -f magenta
- $total = $total + $inactive
- $TotalSnap = $TotalSnap + $Inactive
- }
- "------------ ------------------------- --------------"
- $output = "{0,12} {1,5} " -f $total, $TotalSnap
- write-host $output -f yellow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement