Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function RobocopyReport ($logdir,$exportpath) {
- $report=@()
- gci $logdir | %{
- $summ= [pscustomobject]@{
- Share = $_.name.trim(".txt")
- Dirs = ($_|gc -last 15|Select-String "Dirs.:").tostring().split(':',2)[-1].trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim()
- Files = ($_|gc -last 15|Select-String "Files.:").tostring().split(':',2)[-1].trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim()
- Bytes = ($_|gc -last 15|Select-String "Bytes.:").tostring().split(':',2)[-1].trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim().split(" ",2).trim()
- }
- $bytesvalues=@()
- $bytesunits=@()
- $summ.Bytes|%{
- [string]$InString = $_
- [double]$OutNumber = $null
- if ([double]::TryParse($InString,[ref]$OutNumber)){
- $bytesvalues+=$OutNumber
- }else {
- $bytesunits+=$_
- }
- }
- $summary=[pscustomobject]@{
- Share=$summ.share
- DirsTotal = $summ.dirs[0]
- DirsCopied = $summ.dirs[1]
- DirsSkipped = $summ.dirs[2]
- DirsMismatch = $summ.dirs[3]
- DirsFAILED = $summ.dirs[4]
- DirsExtras = $summ.dirs[5]
- FilesTotal = $summ.files[0]
- FilesCopied = $summ.files[1]
- FilesSkipped = $summ.files[2]
- FilesMismatch = $summ.files[3]
- FilesFAILED = $summ.files[4]
- FilesExtras = $summ.files[5]
- BytesTotal = $bytesvalues[0]
- BytesCopied = $bytesvalues[1]
- BytesSkipped = $bytesvalues[2]
- BytesMismatch = $bytesvalues[3]
- BytesFAILED = $bytesvalues[4]
- BytesExtras = $bytesvalues[5]
- BytesTotalUnit = $bytesunits[0]
- BytesCopiedUnit = $bytesunits[1]
- BytesSkippedUnit = $bytesunits[2]
- BytesMismatchUnit = $bytesunits[3]
- BytesFAILEDUnit = $bytesunits[4]
- BytesExtrasUnit = $bytesunits[5]
- }
- $report+=$summary
- }
- $exportfile = $exportpath + "\" + ($logdir.split("\",99))[-1] + ".csv"
- $report | export-csv -notypeinformation -path $exportfile
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement