Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

backing up event logs, then send to a choice of two central servers, based on site.

$
0
0

Hello,

here goes. I need a PS script to backup event logs of windows 2008R2 servers and Win7 clients. Once backed up, based on which site the host is in, send to the central server in that site. If down, send to the other site. The hostname has the site ref in the name. eg Site1Host1, send to Site1CentralLogServer, if down send to Site2CentralLogServer. So there are many stages of the script, which in total, is beyond me.

I have used this so far (found on net) for the backup of the logs:

 

Function Clear-Eventlogs {            

 Param(

  $Computername = $ENV:COMPUTERNAME,

  [array]$EventLogs = @("application","security"),

  $BackupFolder = "C:\BackupEventLogs2\"

  )            

 Foreach ( $i in $EventLogs ) {

If(!( Test-Path $BackupFolder )) { New-Item $BackupFolder -Type Directory }

 $eventlog="c:\BackupEventLogs\$i" + (Get-Date).tostring("hhmm_ddMMyyyy") + "_" + $Computername + ".evt"

 (get-wmiobject win32_nteventlogfile -ComputerName $computername |

  Where {$_.logfilename -eq "$i"}).backupeventlog($eventlog)            

 Clear-EventLog -LogName $i            

 } end Foreach            

}end function            

Clear-Eventlogs

 

I still have to find a way to determine the central log server and then the best way to send the evt files......

Any help would be really appreciated, as I am only used power shell for basic stuff..

 

thanks

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles