DSCResources/cMonitorPerformanceCounter/cMonitorPerformanceCounter.psm1


function Get-TargetResource {
    [CmdletBinding()]
    [OutputType([Hashtable])]
    param([Parameter(Mandatory=$true)]
[datetime]
$Timestamp,
    [Parameter(Mandatory=$true)]
[string]
$CounterPath)

    @{}
}

function Set-TargetResource {
    [CmdletBinding()]
    
    param([Parameter(Mandatory=$true)]
[datetime]
$Timestamp,
    [Parameter()]
[string]
$CounterType,
    [Parameter()]
[double]
$Value,
    [Parameter(Mandatory=$true)]
[string]
$CounterPath)

    
    Get-Counter

    $DscDataClass  =
        Get-WmiObject -Namespace Root\Microsoft\Windows\DesiredStateConfiguration -List cMonitorPerformanceCounter 
    

    Get-Counter -Counter $counterPath |
        Select-Object -ExpandProperty CounterSamples | 
        ForEach-Object {
            $WmiInfo = $_ 
            $newInstance = $DscDataClass.CreateInstance()
            $newInstance.CounterPath = $WmiInfo.Path
            $newInstance.Value = $WmiInfo.CookedValue
            $newInstance.CounterType = $WmiInfo.CounterType            
            $newInstance.Timestamp = [Management.ManagementDateTimeConverter]::ToDmtfDateTime($wmiInfo.Timestamp)            
            $null = $newInstance.Put()
        }       

}

function Test-TargetResource {
    [CmdletBinding()]
    [OutputType([bool])]
    param([Parameter(Mandatory=$true)]
[datetime]
$Timestamp,
    [Parameter()]
[string]
$CounterType,
    [Parameter()]
[double]
$Value,
    [Parameter(Mandatory=$true)]
[string]
$CounterPath)

    return $false
}

Export-ModuleMember -Function Get-TargetResource, Set-TargetResource, Test-TargetResource