Cartwheel.Directory.psm1
# # Cartwheel_TargetAction.psm1 # function Set-Directory { [OutputType([System.Collections.Hashtable])] [CmdletBinding()] param( [Parameter(Mandatory)] [ValidateSet("Present", "Absent")] [string]$Ensure, [Parameter(Mandatory)] [string]$DirectoryPath ) $modname = $MyInvocation.MyCommand.ModuleName $test = Test-TargetDirectory -DirectoryPath $DirectoryPath -Ensure $Ensure 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 } |