I'm writing a PowerShell script that copies yesterdays logs and zips them. My issue is that I have a massive list of different folders that I need copied. I want to do something like GCI "L:\sites" and take each folder and pipe them into a variable, so instead of a hard path I can use a variable such as $Path. "L:\sites\$path\log" and copy them each into their own L:\logTemp\$Path. Then get the zipping part to zip each one of those folders separately.
Current script below:
Robocopy "l:\sites\TNSERVICE\log" "L:\LogTemp\TNSERVICE" /s /copy:DAT /Maxage:1
set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"
$Date = Get-Date
$Date = $Date.adddays(-1)
$Date2Str = $Date.ToString("yyyMMdd")
sz a -mx=9 "L:\LogTEMP\TNSERVICE $Date2Str.zip" "L:\LogTEMP\TNSERVICE\*"
remove-item L:\LogTemp\TNSERVICE -recurse
GCI "L:\sites"and take each folder and pipe them into a variable" - what stops you?