Private/New-CitrixExportFolders.ps1
<#
.SYNOPSIS Creates a standardized folder structure for exporting Citrix usage and reporting data. .DESCRIPTION The New-CitrixExportFolders function initializes a folder hierarchy under a given root directory. It ensures all required subfolders for exporting Citrix-related data are present, such as folders for session data, VDI info, hypervisor details, and more. This is useful for organizing output before generating or exporting Power BI reports or CSV/json artifacts. .PARAMETER RootPath The root directory where the predefined Citrix export folders will be created. If the root does not exist, it will be created automatically. .EXAMPLE New-CitrixExportFolders -RootPath "C:\Exports\Citrix" Creates the folder structure under "C:\Exports\Citrix" for Citrix reporting purposes. .OUTPUTS None. Creates folders on the filesystem. .NOTES - Subfolders created: CitrixDetails, CitrixSessions, Hypervisors, Json, Licensing, CitrixResourceList, ServerList, VDIList - Logs folder creation using Write-Host #> function New-CitrixExportFolders { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [string]$RootPath ) # Define folder names $folderNames = @( "CitrixDetails", "CitrixSessions", "Hypervisors", # renamed from Hypervisor for clarity "Json", "Licensing", "CitrixResourceList", # renamed from ListOfCitrixResources for readability "ServerList", "VDIList" ) try { # Ensure the root path exists if (-not (Test-Path -Path $RootPath)) { New-Item -Path $RootPath -ItemType Directory -Force | Out-Null Write-Host "✅ Created root folder: $RootPath" } foreach ($folder in $folderNames) { $fullPath = Join-Path -Path $RootPath -ChildPath $folder if (-not (Test-Path -Path $fullPath)) { New-Item -Path $fullPath -ItemType Directory -Force | Out-Null Write-Host "📁 Created folder: $fullPath" } else { Write-Host "📁 Folder already exists: $fullPath" } } } catch { Write-Error "❌ Failed to create folder structure: $_" } } |