zoukankan      html  css  js  c++  java
  • 删除Exchange Server IIS 15天日志

    删除超过15天的IIS日志

    IIS日志文件默认存储在IIS服务器的%SystemDrive%inetpublogsLogFiles文件夹。
    通过创建一个Windows任务计划运行脚本,可以自动化删除日志文件任务。可以使用Windows Task Scheduler安排脚本在任何时间运行。
    脚本从Exchange删除IIS日志。
    可以改变IIS目录。
    Microsoft不支持第三方删除工具

    #Written by David Maugrion - ATOS - david.maugrion@atos.net
    #change the d value to match your policy
    
    $d=-15
    $report = Get-ClientAccessServer | Where-object {Test-Connection -ComputerName $_.Name -Count 1 -Quiet} | Foreach-Object {
        $cas = $_.Name
        Write-Verbose "Making IIS connection to $cas" 
        ([adsi]"IIS://$cas/W3SVC").Children | Where-Object {$_.KeyType -eq 'IIsWebServer'} | Foreach-Object {
            New-Object -TypeName PSObject -Property @{
                #WebSite = $_.ServerComment[0]
                LogLocation = $_.LogFileDirectory[0]
                UncLogLocation = $_.LogFileDirectory[0] -replace "^(.)(.)","\$cas\`$1$"
            }
        }
    }
    
    
    #display the results
    $report
    
    $report | Foreach-Object{
       
    gci -Path $_.UncLogLocation -recurse -include *.log -Force | where -FilterScript {$_.LastWriteTime -le [System.DateTime]::Now.AddDays($d)} | Ri -Force -Confirm:$false
    
    $t=(gci -Path $_.UncLogLocation -recurse -include *.log -Force | where -FilterScript {$_.LastWriteTime -le [System.DateTime]::Now.AddDays($d)}).Count
    $gt=$gt+$t
    }
    if ($gt -gt 0) 
    {Write-Host "$gt Log files deleted" -foregroundcolor yellow}
    else
    {Write-Host "No Log files deleted" -foregroundcolor yellow}
  • 相关阅读:
    Python之正则表达式(re模块)
    正则表达式总结
    Python之日志处理(logging模块)
    Python之向日志输出中添加上下文信息
    python之配置日志的几种方式
    OSG3.4内置Examples解析【目录】
    探究osg中的程序设计模式【目录】
    3wwang的2019计划
    《探索未知种族之osg类生物》目录
    探索未知种族之osg类生物---渲染遍历之裁剪三
  • 原文地址:https://www.cnblogs.com/junjiany/p/7199481.html
Copyright © 2011-2022 走看看