# Copyright (c) 2009 Exemplics LLC # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # Version 2009.3 # function CreateRssItem($logFile) { $rssItem = $logFile.FullName -replace "\.xml",".rssitem.xml" # Generate new rssItem if logFile is newer than rssItem or rssItem # does not exist. if (-not [IO.File]::Exists($rssItem) -or ($logFile.LastWriteTime -gt $(Get-Item $rssItem).LastWriteTime)) { $xmlDoc = New-Object Xml.XmlDocument $xmlDoc.Load($logFile.FullName) $nav = $xmlDoc.CreateNavigator() $writer = New-Object Xml.XmlTextWriter $rssItem,$([Text.Encoding]::UTF8) $argList = New-Object Xml.Xsl.XsltArgumentList $argList.AddParam("uri", "", $env:rssLink + "/" + $logFile.Name) $xslt.Transform($nav, $argList, $writer) $writer.Close() } } function RssStart() { $rssGenerator = $MyInvocation.ScriptName | Split-Path -leaf $header = @( '' '', "", "$rssTitle", "$env:rssLink", "$rssDescription", "en-us", "$(date)", "$(date)", "http://blogs.law.harvard.edu/tech/rss", "$rssGenerator", "$env:rssManagingEditor", "$env:rssWebMaster") return $header } function RssEnd() { $footer = @( "", "") return $footer } # # Push-Location "$env:logDirectory" $rssTitle = "Perforce Backup Procedure Results" $rssDescription = "Summary of Perforce server backup procedure results with links to full results." $xslFile = Convert-Path PerforceBackupProcedureRSS.xsl $xslt = New-Object Xml.Xsl.XslCompiledTransform $xslt.Load($xslFile) Pop-Location # #
Push-Location "$env:logDirectory" # Create RSS fragments in the order the log files were created. Get-ChildItem *.BackupProcedure.xml | Sort-Object LastWriteTime | ForEach-Object { CreateRssItem($_) } RssStart | Out-File "$env:rssFeedFile" -Encoding "UTF8" # Concatenate the RSS fragments newest to oldest. Get-ChildItem *.rssitem.xml | Sort-Object LastWriteTime -Descending | Get-Content | Out-File "$env:rssFeedFile" -Encoding "UTF8" -Append RssEnd | Out-File "$env:rssFeedFile" -Encoding "UTF8" -Append Pop-Location #