Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powershell Text Manipulation Against Robocopy

$
0
0

Hello,

I am using robocopy and would like to do a through analysis of the log file rather than on the robocopy exit codes... not sure if anyone has any better ideas.

robocopy c:\testpath\test\downloads c:\local\downloads /LOG:c:\local\report.txt /MT:16

ok, so that's my copy.

$results = (Get-Content C:\local\report.txt)[-4 .. -4]

OK, so now i have the line on the text file i want to compare which is the bytes Total,Copied,Skipped,Mismarch, Failed, Extras

So they don't all always get populated, in this example total and copied are populated and return in my variable as below.

   Bytes :  871.09 m  871.09 m         0         0         0         0

Now what i want to do is to turn each of the figures on this line to a separate variable so i can then do some calculations before proceeding.

I did a -split however it's a bit all over the place and not sure how to sort this.

$results -split "  "

 Bytes :
871.09 m
871.09 m



 0



 0



 0



 0

Then i dropped that into a file using out-file and ran the below as it wouldn't let me simply pass the parameter into the command.

(gc c:\local\narrowed.txt) | ? {$_.trim() -ne "" }

 Bytes :
871.09 m
871.09 m
 0
 0
 0
 0

Then ran this

$single | select -skip 1

871.09 m
871.09 m
 0
 0
 0
 0

Great now i want each of those lines as a variable.

Anyone have any ideas how i can pull each number out of this line so i can pass them as different variables?

Many Thanks in advance :)




Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>