Copy-File $supportFiles/files folder

Hi Gents,

getting error when running this code , any ideas what might be wrong here:

Copy-File -Path “$dirSupportFiles\Config.xml” -Destination $FileExists -Force
Copy-File : The term ‘Copy-File’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

  • Copy-File -Path “$dirSupportFiles\Config.xml” -Destination $FileEx …
  •   + CategoryInfo          : ObjectNotFound: (Copy-File:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException

This function is a part of the main.ps1 script which either isn’t loaded or failed to load completely.

Is there any other way to copy file from support files to my dest folder?
can you give me an example

Fixed it, using two lines of code:

$filecopypath=dir .\SupportFiles\filesto_copy
Copy-Item $filecopypath -Destination “DESTINATION PATH”

Copy-Item is a basic powershell command that can copy files as well but you should add -Force if you want it to overwrite existing files.

1 Like

Copy-File is a function that is using the Copy-Item cmdlet always with the -Force parameter.
I had to look into the solutions functions file AppDeployToolkitMain.ps1 to determine this.