#---------------------------------------------------------------#
#Script Ttile : deleting SharePoint and SQL 90 days old logs files
#Scrit Author : KRR
#---------------------------------------------------------------#
$SPLogs = "C:\logs" # SharePoint log file location
$SqlLogs = "C:\Sql_logs" #SQL Server Log file location
$path = @($SPLogs,$SqlLogs)
$limit = (Get-Date).AddDays(-90) #log file age
foreach($logs in $path)
{
write-host "SharePoint and SQL logs are deleting!!!!" -ForegroundColor Yellow -BackgroundColor Black
Get-ChildItem $logs -Recurse |where-object{$_.CreationTime -gt $limit} | Remove-Item
write-host "SharePoint and Sql logs deleted sucessfully" -ForegroundColor green -BackgroundColor Black
}
No comments:
Post a Comment