• 4 Posts
  • 10 Comments
Joined 2 months ago
cake
Cake day: March 19th, 2025

help-circle

  • I’m not at all computer, but I believe Out-Null is used as “don’t give me any output”, Out-File is used as “put the output in this file”, and Out-Host is similar to the standard output in the terminal.

    What I would do is something like this (I’m not at a computer to test this):

    Copy-Item "$SourceRoot\$SourceFolder\$SourceFile" -Destination "$DestinationRoot\$DestinationFolder" -Verbose *>&1 | Out-File -FilePath "$LogFile" -Append ; if(Test-Path "$DestinationRoot\$DestinationFolder\$SourceFile"){ Write-Host "Success!" } else { Write-Host "Failed!!!" }
    

    Or if you want the actual output, this will store the result to the file and the screen/host:

    Copy-Item "$SourceRoot\$SourceFolder\$SourceFile" -Destination "$DestinationRoot\$DestinationFolder" *>&1 | Tee-Object -FilePath "$LogFile" -Append | Out-Host