mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-14 20:45:00 +02:00
Updated new-script.ps1
This commit is contained in:
parent
0d3cef0a89
commit
17ca5ec974
@ -7,7 +7,7 @@
|
|||||||
Specifies the path and filename to the new script
|
Specifies the path and filename to the new script
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./new-script myscript.ps1
|
PS> ./new-script myscript.ps1
|
||||||
✅ Created the new 'myscript.ps1' PowerShell script in 1 sec
|
✅ New PowerShell script 'myscript.ps1' created from: C:\PowerShell\data\template.ps1
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -18,12 +18,11 @@ param([string]$filename = "")
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if ($filename -eq "" ) { $filename = Read-Host "Enter the new filename" }
|
if ($filename -eq "" ) { $filename = Read-Host "Enter the new filename" }
|
||||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
|
||||||
|
|
||||||
Copy-Item "$PSScriptRoot/../data/template.ps1" "$filename"
|
$pathToTemplate = Resolve-Path "$PSScriptRoot/../data/template.ps1"
|
||||||
|
Copy-Item $pathToTemplate "$filename"
|
||||||
|
|
||||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
"✅ New PowerShell script '$filename' created from: $pathToTemplate"
|
||||||
"✅ Created the new '$filename' PowerShell script in $elapsed sec"
|
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user