Functions/Copy-SECSecretValue.ps1

function Copy-TSECSecretValue {
    param (
        [Parameter(Mandatory=$true)]
        [string]$NewSMName,
        [Parameter(Mandatory=$true)]
        [string]$SourceSMName,
        [string]$creator
    )
    $ErrorActionPreference = 'Stop'
    
    $SourceSM = Get-SECSecretValue -SecretId $SourceSMName

    $Description = "Cloned from [$SourceSMName]"
    
    if(-not $creator)
    {
        $creator = 'Powershell'
    }
    $Tags = @(@{Key="creator";Value="$creator"},@{Key="createdtype";Value="auto"})
    $NedSM = New-SECSecret -SecretString $SourceSM.SecretString -Name $NewSMName -Description $Description -Tag $Tags
    return $NedSM
}