Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for dhcpbackup.ps

(view source code of dhcpbackup.ps as plain text)

  1. #*****************************************************************
  2. #
  3. #   Script Name:  dhcpBackup.ps1
  4. #   Version:  1.0
  5. #   Author:  Jason Carter
  6. #   Date:  August 30,  2007
  7. #
  8. #   Description:  Used to backup DHCP logs from the DHCP server
  9. #   to another storage device for archiving purposes.
  10. #
  11. #*****************************************************************
  12.  
  13. # Get Yestedays Date In Month, Day, Year format
  14. $yesterday = ( Get-Date ( Get-Date ).AddDays(-1) -uformat %m%d%Y )
  15.  
  16. # Get the first 3 letters of the day name from yesterday
  17. $logdate=( [string]( ( Get-Date ).AddDays(-1).DayofWeek ) ).SubString(0,3)
  18.  
  19. # Change path to DHCP log folder, copy yesterdays log file to backup location
  20. Set-Location "C:\WINDOWS\System32\dhcp"
  21. Copy-Item "DhcpSrvLog-$logdate.log" "D:\DHCPBACKUP"
  22.  
  23. # Rename log file with yesterdays date
  24. Set-Location "D:\DHCPBACKUP"
  25. Rename-Item "DhcpSrvLog-$logdate.log" "$yesterday.log"
  26.  

page last modified: 2024-04-16; loaded in 0.0067 seconds