Deploy folder to desired path - PowerShell function I am still learning PowerShell and I would like your opinion on my folder deployment PowerShell function. It basically check if a defined folder exists and creates it if it does not and writes it actions to log and console.
&lt;#
.SYNOPSIS
Creates folder if it does not already exists.
.DESCRIPTION
This function check if defined transfer folder exists and if not it creates it on remote computer.
.PARAMETER Path
Full path of the folder.
.PARAMETER Cancel
If Cancel parameter set to true the folder deployment is canceled. This is used in pipeline when it is important to skip this
operation if last operation failed.
.EXAMPLE
Deploy-Folder -Path 'D:\Folder\Folder'
#&gt;
function Deploy-Folder {
    param (
        [Parameter(Position = 0, Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
        [String]
        $Path,

        [Parameter(Position = 1, ValueFromPipeline, ValueFromPipelineByPropertyName)]
        [boolean]
        $Cancel = $false
    )

    begin {
        Import-Module '.\Write-Log.psm1'
    }

    process {   
        if(-not $Cancel) {
            if((Test-Path $Path) -eq $true) {
                $Message = &quot;Successfully accessed &quot; + $Path + &quot; folder&quot;
                $OperationResult  = 'Success'
            }
            else {
                try {
                    New-Item -Path $Path -ItemType &quot;Directory&quot;
                }
                catch {
                    $Message = &quot;Failed to create &quot; + $Path + &quot; folder `n&quot; + $_.Exception
                    $OperationResult  = 'Fail'
                }

                if((Test-Path $Path) -eq $true) {
                    $Message = &quot;Successfully created &quot; + $Path + &quot; folder&quot;
                    $OperationResult  = 'Success'
                }
            }
        }
        else {
            $Message = &quot;Canceled &quot; + $Path + &quot; folder deployment&quot;
            $OperationResult  = 'Success'
        }

        Write-Log -OperationResult $OperationResult -Message $message

        if($OperationResult -ne 'Fail') {
            $Cancel = $false
        }
        else {
            $Cancel = $true
        }
        
        New-Object -TypeName psobject -Property @{
            Cancel = $Cancel
        }
    }
}
The code is very cleanly written, and its easy to see what is going on.
The verb you are using for the command is not officially 'supported'. Every command should stick to the official list of verbs, that can be checked with get-verb.  would suggest New-Folder
I don't know why you go through this much code to create a folder when you could append a -force to the back end of the new-item command. I guess if you have a system that required you to log every instance where one would create a folder, this would make sense.
If you have a system where you do commands to an external module, i would suggest you look into the #require tag in powershell, instead of having import-module at the start of your command
you can easily cast to a psobject just by doing [PSCustomObject]@{cancel=$cancel}.
use [CmdletBinding()] at the start of your function to get powershell standard switches (-verbose, -debug, -erroraction etc..). just put it between the function definition line and the param definition line (line 2)