mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-30 15:08:49 +02:00
Added touch.ps1
This commit is contained in:
parent
4908e13746
commit
53345ebdcf
27
scripts/touch.ps1
Normal file
27
scripts/touch.ps1
Normal file
@ -0,0 +1,27 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Create an empty file
|
||||
.DESCRIPTION
|
||||
This PowerShell script creates a new empty file.
|
||||
.PARAMETER filename
|
||||
Path and filename of the new file
|
||||
.EXAMPLE
|
||||
PS> ./touch.ps1 test.txt
|
||||
✅ Created a new empty file called 'test.txt'.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$filename = "")
|
||||
|
||||
try {
|
||||
if ($filename -eq "") { $filename = Read-Host "Enter the filename" }
|
||||
"" | Out-File $filename -encoding ASCII
|
||||
"✅ Created a new empty file called '$filename'."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
exit 1
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user