Copy files with Robocopy and create a htm report with Orchestrator

This is an example on how to copy files and folders with Robocopy in Orchestrator. At the end the Runbook converts the Robocopy report to a html page so it can be easily read with a web browser.

This is the Runbook.

Copy files with Robocopy and create a htm report with Orchestrator1

The “Run Program” activity “Run Robocopy” looks as the following with the command: C:\Windows\System32\Robocopy.exe “C:\From” “C:\To” /S /E /PURGE /LOG:”C:\tmp\RobocopyLog.txt” /np

Copy files with Robocopy and create a htm report with Orchestrator2

The “Run .Net Script” activity “Convert txt file to htm Properties” is seen below.

Copy files with Robocopy and create a htm report with Orchestrator3

The PowerShell script is borrowed from the site Life of a Geek Admin but I modified it some to fit my needs. Here is how my script looks like.

$SourceFile=”C:\tmp\RobocopyLog.txt”
$TargetFile=”C:\tmp\StatusLog.htm”
$File=Get-Content$SourceFile
$FileLine= @()
Foreach ($Linein$File) {
 $MyObject=New-Object-TypeNamePSObject
 Add-Member-InputObject$MyObject-TypeNoteProperty-NameRobocopy-Value$Line
 $FileLine+=$MyObject
}
$FileLine|ConvertTo-Html-PropertyRobocopy|Out-File$TargetFile
 
When running this Runbook it copies the files and folders from “C:\From” to “C:\To” and then creates a web report that looks as this.Copy files with Robocopy and create a htm report with Orchestrator4

 

No comments yet.

Leave a Reply