#***************************************************************** # # Script Name: dhcpBackup.ps1 # Version: 1.0 # Author: Jason Carter # Date: August 30, 2007 # # Description: Used to backup DHCP logs from the DHCP server # to another storage device for archiving purposes. # #***************************************************************** # Get Yestedays Date In Month, Day, Year format $yesterday = ( Get-Date ( Get-Date ).AddDays(-1) -uformat %m%d%Y ) # Get the first 3 letters of the day name from yesterday $logdate=( [string]( ( Get-Date ).AddDays(-1).DayofWeek ) ).SubString(0,3) # Change path to DHCP log folder, copy yesterdays log file to backup location Set-Location "C:\WINDOWS\System32\dhcp" Copy-Item "DhcpSrvLog-$logdate.log" "D:\DHCPBACKUP" # Rename log file with yesterdays date Set-Location "D:\DHCPBACKUP" Rename-Item "DhcpSrvLog-$logdate.log" "$yesterday.log"