I’m having a problem with Copy-File. I’m trying to rename the file as I copy it, and it appears that if the destination is a file, it does not create the path if necessary.
I’m basing this off the issues I’m experiencing and this from Copy-File
If ((-not ([IO.Path]::HasExtension($Destination))) -and (-not (Test-Path -LiteralPath $Destination -PathType 'Container'))) {
Write-Log -Message "Destination folder does not exist, creating destination folder [$destination]." -Source ${CmdletName}
$null = New-Item -Path $Destination -Type 'Directory' -Force -ErrorAction 'Stop'
}
Is that correct? or am I doing something wonky?