1
We have several servers that save log files locally and I'm trying to automate logging to a single network location with a name of the parent folder where log files are stored and date modified time stamp
Server 1 D:\Projects\Ohio\(Rel1)\BuildScripts\logs
Server 2 D:\Projects\Ohio\(Rel2)\BuildScripts\logs
Server 3 D:\Projects\Ohio\(Rel3)\BuildScripts\logs
Trying to copy all logs to R:\Logs\CruiseControl\(Rel.AW) \logs+timestamp\logfiles.txt
So far I'm able to set this up for Server 1 with the script below but the problem is that the same script needs to be called by Server 1, Server 2 and Server 3 and each time logs need to go to specific stream (Rel1, Rel2, Rel3) How can I reference the stream name ?
$logDir = 'D:\Projects\Ohio\Rel.AW\BuildScripts\logs'
$copyDir = 'R:\Logs\CruiseControl\Rel.AW'
Get-ChildItem $logDir -File | ForEach {
$parentFolder = $_.Directory.Name
$timeStamp = $_.LastWriteTime.ToString('MMddyyyy')
$path = Join-Path -Path $copyDir -ChildPath "$($parentFolder)_$($timeStamp)"
Write-Host "Path to copy to is: $path" -ForegroundColor Green
}
robocopy $logDir $path /log+:R:\Logs\CruiseControl\Rel.AW\log