From 17ca5ec974ac7b6453ff084f6df4f0a32abdaf93 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Fri, 9 May 2025 11:30:57 +0200 Subject: [PATCH] Updated new-script.ps1 --- scripts/new-script.ps1 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/new-script.ps1 b/scripts/new-script.ps1 index 5bebf39e..0df107b2 100755 --- a/scripts/new-script.ps1 +++ b/scripts/new-script.ps1 @@ -7,7 +7,7 @@ Specifies the path and filename to the new script .EXAMPLE 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 https://github.com/fleschutz/PowerShell .NOTES @@ -18,12 +18,11 @@ param([string]$filename = "") try { 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 - "✅ Created the new '$filename' PowerShell script in $elapsed sec" + "✅ New PowerShell script '$filename' created from: $pathToTemplate" exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"