(view source code of dhcpbackup.ps as plain text)
#*****************************************************************
#
# 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"
page last modified: 2024-04-16; loaded in 0.0067 seconds