Question

How can you create a script to copy files with Automox?

  • 7 March 2023
  • 0 replies
  • 27 views

Badge

Hello, I am using Automox agent to copy a test file. The file is called "hello_world.txt" and the location where I can upload it is "c:". Additionally, I have added "Exit 1" to get a response, but I still don't understand how Exit 1 works. My script checks if the file already exists before copying it. If it does not exist, it makes a copy and responds "New file created".

Someone help me, because the script don't work?

$filename = 'hello_world.txt'
$filepath = 'C:\'

If
    (Test-Path -Path $filepath$filename -PathType Leaf)
    {
      Copy-Item .\$filename -Destination $filepath
      Write-Output "File copied and replaced existing"
    }
else
    {
      Copy-Item .\$filename -Destination $filepath
      Write-Output "New file created"
    }


0 replies

Be the first to reply!

Reply