Advertisement
Advertisement
| 09.08.2008 at 11:51AM PDT, ID: 23713118 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: |
#----------------------------------------------------
# This script is writen in Powershell v1.0 to remotely retreive
# event logs and store them on the local system.
# Created Blankmonkey 8/25/8
#----------------------------------------------------
#----------------------------------------------------
# First we get the server list to get the logs from
#----------------------------------------------------
$list = Get-Content "servers.txt"
#----------------------------------------------------
# DISABLED -- Now we get the credintials. Note this is once for all the computers in the list,
# so use differant lists for differant domains.
#----------------------------------------------------
#$domainUser = Read-Host "Enter your domain User ID in the form <Domain>\<UserID>"
#$domainPass = Read-Host "Enter your password" -asSecureString
#----------------------------------------------------
# We start the loop, and use the $Server variable in the loop form the input file
#----------------------------------------------------
foreach($server in $list)
{
#----------------------------------------------------
# get the date, this is for later file naming
#----------------------------------------------------
$a = get-date -f yyyy-MM-dd-HH-mm-ss
#----------------------------------------------------
# The wmi query to find which event logs are on the system
#----------------------------------------------------
$logNames = Get-WmiObject Win32_NTEventLogFile -comp $Server
#----------------------------------------------------
# A For loop that gets the all the logs, but first creates the local dir to backup the evt
#----------------------------------------------------
If(!(Test-Path "\\$Server\c$\LogBackups")){New-Item "\\$Server\c$\LogBackups" -type Directory -force | out-Null}
foreach($log in $logNames)
{
$log
$path = "\\{0}\c$\LogBackups\{0}$a{1}.evt" -f $Server,$log.LogFileName
$result = ($log.BackupEventLog($path)).ReturnValue
move-Item $path -dest "C:\Logs\Backup\" -force
$result
if($result -eq 0){$log.ClearEventLog()}
else {cmd /c blat -body "The Server $server failed to dump the logs with result error $result" -t me@me.com -s "$server Log dump errored out with error: $result" }
if($result -ne 0) {break}
}
#----------------------------------------------------
# Now delete all files older then 14 days
#----------------------------------------------------
$oldlogfiles = Get-ChildItem C:\Logs\Backup
foreach($x in $oldlogfiles)
{
$y = ((Get-Date) - $x.CreationTime).Days
if ($y -gt 14 -and $x.PsISContainer -ne $True)
{$x.Delete()}
}
}
|