Files
automations-calendar-OPEN/scripts/copy-workbook.ps1
2026-09-22 07:50:20 -06:00

12 lines
528 B
PowerShell

[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory)][string]$Source,
[Parameter(Mandatory)][string]$Destination
)
$ErrorActionPreference = 'Stop'
if (-not (Test-Path -LiteralPath $Source -PathType Leaf)) { throw 'Source workbook is missing.' }
if (Test-Path -LiteralPath $Destination) { throw 'Destination exists; choose a new file path.' }
if ($PSCmdlet.ShouldProcess($Destination, 'Copy workbook')) {
[IO.File]::Copy([IO.Path]::GetFullPath($Source), [IO.Path]::GetFullPath($Destination), $false)
}