Clear-OldIISLog
SYNOPSIS
A script to clean out old IIS log files.
SYNTAX
Clear-OldIISLog [[-Days] <Int16>] [-WhatIf] [-Confirm]
[<CommonParameters>]
DESCRIPTION
This script will clean out IIS log files older than x days.
EXAMPLES
EXAMPLE 1
Clear-OldIISLog -Days 60
Removes all IIS log files that are older than 60 days.
PARAMETERS
-Days
The number of days to keep log files. The default is 60 days.
Type: Int16
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: 60
Accept pipeline input: False
Accept wildcard characters: False
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
If the WebAdministration module is available, it will use that to check the specific log file locations for each web site. Otherwise, it checks the assumed default log folder location and the registry for the IIS log file location.
Future enhancements may add a summary of which locations were processed and how many log files were removed.