Skip to content

Instantly share code, notes, and snippets.

@mercdev
mercdev / iis-applications.ps1
Created May 2, 2015 23:04
Displays Applications configured in IIS
# 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
@mortenya
mortenya / Remove-OldIISLogs.ps1
Last active March 7, 2024 17:27
Script to run as a Scheduled Task to clean out IIS logs older than 30 days.
<#
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))