DSCResources/src/cBinPlace.1.0.resource.ps1

Write-DSCResource <#-ResourceName cBinPlace -ModuleRoot $sysModules\cFg #>-Property @{
    OutputPath = "The output path"
    Base64Content = "The file contents, in base64"
} -Test {
    if (-not [IO.File]::Exists($OutputPath)) {
        return $false
    }
    $b64 = [Convert]::FromBase64String($Base64Content)
    $md5 = [Security.Cryptography.MD5]::Create()
    $hash1 = [BitConverter]::ToString($md5.ComputeHash($b64))    
    $hash2 = [BitConverter]::ToString($md5.ComputeHash([IO.File]::ReadAllBytes($OutputPath)))
    $hash1 -eq $hash2
} -Get {
    @{
        OutputPath = $outputPath
        Base64Content = try {
            [Convert]::ToBase64String([IO.File]::ReadAllBytes($outputPath))
        } catch {
            $null
        }
    }
} -Set {
    if (-not (Test-Path $outputPath)) {
        $nf = New-Item -Path $outputPath -Force -ItemType File
    }
    [IO.File]::WriteAllBytes($outputPath, [Convert]::FromBase64String($base64Content))        
} -KeyProperty OutputPath