Private/Create-CitrixReportFolders.ps1

<#
.SYNOPSIS
    Creates the required folder structure for Citrix reports.
 
.DESCRIPTION
    The `Create-CitrixReportFolders` function takes an input location and creates a standardized
    folder structure for Citrix reports. This includes a `Monthly` folder and a `Daily` folder with
    `CSV` and `EXCEL` subdirectories.
 
.PARAMETER Location
    The root location where the folder structure should be created.
 
.EXAMPLE
    Create-CitrixReportFolders -Location "C:\Reports"
 
.NOTES
    Author: [Your Name]
    Date: [Today's Date]
    Version: 1.0
#>

Function Create-CitrixReportFolders {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]$Location
    )

    try {
        # Normalize the location path
        $RootPath = Resolve-Path -Path $Location -ErrorAction SilentlyContinue
        if (-not $RootPath) { $RootPath = $Location }

        # Define folder structure
        $folders = @(
            "Monthly",
            "Daily\CSV",
            "Daily\EXCEL"
        )

        # Create folders
        foreach ($folder in $folders) {
            $fullPath = Join-Path -Path $RootPath -ChildPath $folder

            if (-not (Test-Path -Path $fullPath)) {
                New-Item -Path $fullPath -ItemType Directory -Force | Out-Null
                Write-Host "[SUCCESS] Created folder: $fullPath" -ForegroundColor Green
            } else {
                Write-Host "[INFO] Folder already exists: $fullPath" -ForegroundColor Yellow
            }
        }

        Write-Host "`n[COMPLETED] Folder structure setup successfully at: $RootPath" -ForegroundColor Cyan

    } catch {
        Write-Host "[ERROR] Failed to create folders: $($_.Exception.Message)" -ForegroundColor Red
    }
}