DSCResources/Cartwheel_xBlank/Cartwheel_xBlank.psm1

#
# Cartwheel_xBlank.psm1
# xBlank is a simplified boilerplate template for new modules
#




function Test-TargetResource 
{
    param 
    (    
    
        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [string]$DirectoryPath, 

        [Parameter(Mandatory)]   
        [ValidateSet("Present", "Absent")]
        [string]$Ensure = "Present"
     
    )

  

$testTargetResourceResult = Test-Path -PathType Container -path $DirectoryPath  -ErrorVariable ItemErr -ErrorAction SilentlyContinue ;
$test = Test-Target $Ensure $testTargetResourceResult $ItemErr $DirectoryPath
return $test.ReturnValue
}






# The Set-TargetResource function is used to create, delete or configure on the target machine.
function Set-TargetResource 
{
    [CmdletBinding(SupportsShouldProcess=$true)]
    param 
    (       
        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [string]$DirectoryPath,
    
        [Parameter(Mandatory)]   
        [ValidateSet("Present", "Absent")]
        [string]$Ensure = "Present"

    )

  

$modname = $MyInvocation.MyCommand.ModuleName
$testTargetResourceResult = Test-Path -PathType Container -path $DirectoryPath  -ErrorVariable ItemErr -ErrorAction SilentlyContinue ;
$test = Test-Target $Ensure $testTargetResourceResult $ItemErr $DirectoryPath

    if ($test.Command -eq "Add") {
        New-Item -ItemType Directory -Force -Path $DirectoryPath
        Write-Verbose  "$modname : Item ($DirectoryPath) in wrong state... added."
    }
    if ($test.Command -eq "Remove") {
        Remove-Item -Recurse -Force $DirectoryPath
        Write-Verbose  "$modname : Item ($DirectoryPath) in wrong state... removed."
    }
    if ($test.Command -eq "Skip") {
        Write-Verbose  "$modname : Item ($DirectoryPath) in correct state."
    }
    if ($test.Command -eq "Error") {
        Write-Verbose  "$modname : Item ($DirectoryPath) had errors."
    }

return $test.ReturnValue
}







function Get-TargetResource 
{
    param 
    (    
    
        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [string]$DirectoryPath, 

        [Parameter(Mandatory)]   
        [ValidateSet("Present", "Absent")]
        [string]$Ensure = "Present"
     
    )


    Write-Verbose  "$modname : Running Test for ($DirectoryPath)."
    Test-TargetResource $DirectoryPath $Ensure



}


Export-ModuleMember -Function *-TargetResource