The *new-text-file.ps1* Script =========================== This PowerShell script creates a new .txt file from template file at: ../data/templates/Text.txt. Parameters ---------- ```powershell /Repos/PowerShell/scripts/new-text-file.ps1 [[-path] ] [] -path Specifies the path and new filename Required? false Position? 1 Default value Accept pipeline input? false Aliases Accept wildcard characters? false [] This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` Example ------- ```powershell PS> ./new-text-file.ps1 README.txt ✅ New text file 'README.txt' created from template 'Text.txt'. ``` Notes ----- Author: Markus Fleschutz | License: CC0 Related Links ------------- https://github.com/fleschutz/PowerShell Script Content -------------- ```powershell <# .SYNOPSIS Creates a new text file .DESCRIPTION This PowerShell script creates a new .txt file from template file at: ../data/templates/Text.txt. .PARAMETER path Specifies the path and new filename .EXAMPLE PS> ./new-text-file.ps1 README.txt ✅ New text file 'README.txt' created from template 'Text.txt'. .LINK https://github.com/fleschutz/PowerShell .NOTES Author: Markus Fleschutz | License: CC0 #> param([string]$path = "") try { if ($path -eq "" ) { $path = Read-Host "Enter the new filename" } $pathToTemplate = Resolve-Path "$PSScriptRoot/../data/templates/Text.txt" Copy-Item $pathToTemplate "$path" if ($lastExitCode -ne 0) { throw "Can't copy template to: $path" } "✅ New text file '$path' created from template 'Text.txt'." exit 0 # success } catch { "⚠️ Error: $($Error[0])" exit 1 } ``` *(page generated by convert-ps2md.ps1 as of 05/12/2025 22:02:56)*