This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# note: requires Web Administration (IIS) Provider for Windows PowerShell | |
# http://technet.microsoft.com/en-us/library/ee909471(v=ws.10).aspx | |
cls | |
try | |
{ | |
Import-Module WebAdministration | |
#Get-WebApplication |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Shamelessly liberated from http://foxdeploy.com/2015/02/11/automatically-delete-old-iis-logs-w-powershell/ | |
Because it was better than my own. | |
#> | |
$LogPath = "C:\inetpub\logs" | |
$maxDaystoKeep = -30 | |
$outputPath = "c:\CleanupTask\Cleanup_Old_logs.log" | |
$itemsToDelete = dir $LogPath -Recurse -File *.log | Where LastWriteTime -lt ((get-date).AddDays($maxDaystoKeep)) |