Public/New-pseFolder.ps1

function New-pseFolder {
    <#
    .SYNOPSIS
    Creates a new folder at the specified path if it does not already exist.
 
    .DESCRIPTION
    The New-pseFolder function creates a new folder at the specified path if it does not already exist.
    If the folder already exists, it provides a message indicating that the folder is already present (using Write-Host).
 
    .PARAMETER Path
    Specifies the path where the new folder should be created. It accepts input from pipeline or direct parameter input.
 
    .EXAMPLE
    "C:\ExampleFolder", "C:\AnotherFolder" | New-pseFolder
    Creates new folders at the paths "C:\ExampleFolder" and "C:\AnotherFolder" sent through the pipeline.
 
    .EXAMPLE
    New-pseFolder -Filepath "C:\ExampleFolder", "C:\AnotherFolder"
    Creates new folders at the paths "C:\ExampleFolder" and "C:\AnotherFolder" provided via the -Filepath parameter.
 
    .INPUTS
    System.String[]
 
    .NOTES
    Author : owen.heaume
    Version : 1.0.0 - Initial release
    #>


    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
        [string[]]$Filepath
    )

    process {
        foreach ($path in $Filepath) {
            try {
                # Check if the folder already exists
                if (!(Test-Path -Path $path -PathType Container)) {
                    Write-Host "Creating folder '$path'" -ForegroundColor DarkGray
                    New-Item -ItemType Directory -Path $path -ErrorAction Stop
                    Write-Host "Folder '$path' created" -ForegroundColor DarkGreen
                } else {
                    Write-Host "Folder '$path' already exists" -ForegroundColor DarkYellow
                }
            } catch {
                Write-Error "Failed to create folder '$path': $_"
            }
        }
    }
}