<DataSourceModuleType ID="Microsoft.Windows.FileServices.Service.Deduplication.6.3.GetDedupStatus" Accessibility="Internal">
<Configuration>
<xsd:element name="IntervalSeconds" type="xsd:integer"/>
<xsd:element name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element name="SyncTime" type="xsd:string"/>
<xsd:element name="ComputerName" type="xsd:string"/>
<xsd:element name="VolumeId" type="xsd:string"/>
</Configuration>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource ID="Script" TypeID="Windows!Microsoft.Windows.TimedScript.PropertyBagProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime>$Config/SyncTime$</SyncTime>
<ScriptName>Dedup62.GetDedupStatus.vbs</ScriptName>
<Arguments>$Config/ComputerName$</Arguments>
<ScriptBody><Script>
Option Explicit
SetLocale("en-us")
Dim e: set e = New Error
Dim computerName: computerName = WScript.Arguments(0)
On Error Resume Next
Dim omAPI: Set omAPI = CreateObject("MOM.ScriptAPI")
e.Save
On Error Goto 0
If IsEmpty(omAPI) or e.Number <> 0 Then
WScript.Quit
End If
Dim oWMI
On Error Resume Next
set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate, authenticationLevel=pktPrivacy}!\\" & computerName & "\root\Microsoft\Windows\Deduplication")
e.Save
On Error Goto 0
If Not(IsEmpty(oWMI)) Then
On Error Resume Next
Dim dedupVolumes: Set dedupVolumes = oWMI.ExecQuery("SELECT VolumeId, Volume, LastOptimizationTime, LastGarbageCollectionTime, LastScrubbingTime, OptimizedFilesCount, OptimizedFilesSize, InPolicyFilesCount, InPolicyFilesSize, SavingsRate from MSFT_DedupVolumeStatus")
Dim dedupVolume, omBag
Dim lastRunTime: Set lastRunTime = CreateObject ("WbemSCripting.SWbemDateTime")
For Each dedupVolume in dedupVolumes
Set omBag= omAPI.CreatePropertyBag()
Call omBag.AddValue("VolumeId", dedupVolume.VolumeId)
Call omBag.AddValue("Volume", dedupVolume.Volume)
If dedupVolume.LastOptimizationTime <> "null" Then
lastRunTime.Value = dedupVolume.LastOptimizationTime
call omBag.AddValue("DaysSinceLastOptimization", DateDiff("d",lastRunTime.GetVarDate, Now))
Else
call omBag.AddValue("DaysSinceLastOptimization", -1)
End If
If dedupVolume.LastGarbageCollectionTime <> "null" Then
lastRunTime.Value = dedupVolume.LastGarbageCollectionTime
call omBag.AddValue("DaysSinceLastGarbageCollection", DateDiff("d",lastRunTime.GetVarDate, Now))
Else
call omBag.AddValue("DaysSinceLastGarbageCollection", -1)
End If
If dedupVolume.LastScrubbingTime <> "null" Then
lastRunTime.Value = dedupVolume.LastScrubbingTime
call omBag.AddValue("DaysSinceLastScrubbing", DateDiff("d",lastRunTime.GetVarDate, Now))
Else
call omBag.AddValue("DaysSinceLastScrubbing", -1)
End If
Call omBag.AddValue("OptimizedFilesCount", dedupVolume.OptimizedFilesCount)
Call omBag.AddValue("OptimizedFilesSize", dedupVolume.OptimizedFilesSize)
Call omBag.AddValue("InPolicyFilesCount", dedupVolume.InPolicyFilesCount)
Call omBag.AddValue("InPolicyFilesSize", dedupVolume.InPolicyFilesSize)
If dedupVolume.InPolicyFilesCount > 0 Then
Call omBag.AddValue("DedupCompletionPercent", dedupVolume.OptimizedFilesCount / dedupVolume.InPolicyFilesCount * 100)
Else
Call omBag.AddValue("DedupCompletionPercent", 0)
End If
Call omBag.AddValue("SavingsRate", dedupVolume.SavingsRate)
omAPI.AddItem(omBag)
Next
On Error Goto 0
Call omAPI.ReturnItems()
End If
Class Error
Public Description
Public Number
Public Source
Sub Class_Initialize()
Number = 0
End Sub
Sub Save
Description = Err.Description
Number = Err.Number
Source = Err.Source
Err.Clear
End Sub
Sub Raise(strDescription)
Err.Raise Number, Source, strDescription & GetErrorString(Number, Description)
End Sub
End Class