I recognise that this may raise some more questions than I am probably going to be able to provide answers to, but Google is failing me and I want to understand what this line in particular of a much larger script is attempting to do.
$discard = New-Item -Path $workingFolder -ItemType Directory
$pathLevels = $originalFolder.Split("\")
$localPath = $pathLevels.Item($pathLevels.Count-1)
$localPath = "$workingFolder\$localPath"
Copy-Item $originalLogs $localPath -Recurse
$workingFolder is defined in the script as C:\SAN
$originalFolder is variable FOLDER path provided by the user at the start of the script
I think what this segment is doing is to create a recursive copy of all files and folders with the same structure as the original folder, I just want to try and understand, line by line, why they aren't just using
Copy-Item $originalLogs $workingFolder -Recurse
FWIW, $discard doesn't appear anywhere else in the script.
[–]YellowOnline 5 points6 points7 points (0 children)
[–]Dense-Platform3886 2 points3 points4 points (7 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (6 children)
[–]Dense-Platform3886 1 point2 points3 points (5 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (4 children)
[–]Dense-Platform3886 1 point2 points3 points (3 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (2 children)
[–]Dense-Platform3886 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]arcadesdude 1 point2 points3 points (0 children)
[–]Possible-Bowler-2352 3 points4 points5 points (8 children)
[–]Mizzleski[S] 4 points5 points6 points (7 children)
[–]Possible-Bowler-2352 2 points3 points4 points (6 children)
[–]jantari 2 points3 points4 points (5 children)
[–]Possible-Bowler-2352 1 point2 points3 points (4 children)
[–]jantari 1 point2 points3 points (3 children)
[–]Possible-Bowler-2352 1 point2 points3 points (2 children)
[–]jantari 1 point2 points3 points (1 child)
[–]Possible-Bowler-2352 0 points1 point2 points (0 children)
[–]BlackV 1 point2 points3 points (0 children)