mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-11 21:59:11 +02:00
Updated the manuals
This commit is contained in:
78
docs/new-markdown-file.md
Normal file
78
docs/new-markdown-file.md
Normal file
@ -0,0 +1,78 @@
|
||||
The *new-markdown-file.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script creates a new Markdown file from template file at: ../data/templates/Markdown.md.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
/Repos/PowerShell/scripts/new-markdown-file.ps1 [[-path] <String>] [<CommonParameters>]
|
||||
|
||||
-path <String>
|
||||
Specifies the path and new filename
|
||||
|
||||
Required? false
|
||||
Position? 1
|
||||
Default value
|
||||
Accept pipeline input? false
|
||||
Aliases
|
||||
Accept wildcard characters? false
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./new-markdown-file.ps1 letter.md
|
||||
✅ New Markdown file 'letter.md' created from template 'Markdown.md'.
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/fleschutz/PowerShell
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Creates a new Markdown file
|
||||
.DESCRIPTION
|
||||
This PowerShell script creates a new Markdown file from template file at: ../data/templates/Markdown.md.
|
||||
.PARAMETER path
|
||||
Specifies the path and new filename
|
||||
.EXAMPLE
|
||||
PS> ./new-markdown-file.ps1 letter.md
|
||||
✅ New Markdown file 'letter.md' created from template 'Markdown.md'.
|
||||
.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/Markdown.md"
|
||||
Copy-Item $pathToTemplate "$path"
|
||||
if ($lastExitCode -ne 0) { throw "Can't copy template to: $path" }
|
||||
|
||||
"✅ New Markdown file '$path' created from template 'Markdown.md'."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 05/12/2025 22:02:56)*
|
Reference in New Issue
Block a user