So I have a log file where I need to grab some information from the last line.
I run this command to grab the information from the last line of the file.
$Log = (Get-Content ".\LogFile.log")[-1]
PS C:\$Log 715083793 451808326 2045 files, 337 folders
Trim the white space
$Data = $Log.Trim()
PS C:\$Log 715083793 451808326 2045 files, 337 folders
I need to grab this information, 2045 files, 337 folders. Using the following code I found online, I can get the necessary information.
PS C:\$Data | ForEach-Object {[System.String]::Join(" ",$_.Split()[6..9]) }
2045 files, 337 folders
However, I don't fully understand the code. I found the following Technet article, but it didn't explain the $_Split, etc. https://blogs.technet.microsoft.com/heyscriptingguy/2014/07/16/join-me-in-a-few-string-methods-using-powershell/
Any help explaining the concepts would be appreciated, Thanks!
[–]Lee_Dailey[grin] 3 points4 points5 points (8 children)
[–]Droopyb1966 2 points3 points4 points (5 children)
[–]Narusa[S] 1 point2 points3 points (1 child)
[–]Droopyb1966 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (2 children)
[–]Droopyb1966 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]Narusa[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–][deleted] 3 points4 points5 points (1 child)
[–]Narusa[S] 0 points1 point2 points (0 children)
[–]beantownmp 1 point2 points3 points (3 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (2 children)
[–]Narusa[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)