Easily query IIS logs.
Get-IisLog.ps1 [-ComputerName <String[]>] [[-After] <DateTime>] [[-Before] <DateTime>] [-IpAddr <String[]>]
[-Username <String[]>] [-Status <Int32[]>] [-Method <WebRequestMethod[]>] [-UriPathLike <String>]
[-QueryLike <String>] [-ReferrerLike <String>] [-LogFormat <String>] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
Get-IisLog.ps1 [-LogDirectory <DirectoryInfo[]>] [[-After] <DateTime>] [[-Before] <DateTime>]
[-IpAddr <String[]>] [-Username <String[]>] [-Status <Int32[]>] [-Method <WebRequestMethod[]>]
[-UriPathLike <String>] [-QueryLike <String>] [-ReferrerLike <String>] [-LogFormat <String>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
Get-IisLog.ps1 -LogDirectory \\Server\c$\inetpub\logs\LogFiles\W3SVC1 -After 2014-03-30 -UriPathLike '/WebApp/%' |select -First 1
Time : 2014-03-31 15:56:45 Server : 192.168.1.99:80 Filename : ex140331.log Line : 121555 IpAddr : 192.168.1.199 Username : UserAgent : Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3) Method : GET UriPath : /WebApp/ Query : Referrer : StatusCode : 401 Status : Unauthorized SubStatusCode : 2 SubStatus : Logon failed due to server configuration. WinStatusCode : 5 WinStatus : Access is denied
Attempts to use the LogFiles$ share of the computers listed as the log directory.
Type: String[]
Parameter Sets: Server
Aliases: Server, CN
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The directory(ies) containing the log files to query.
Type: DirectoryInfo[]
Parameter Sets: Directory
Aliases: Dir
Required: False
Position: Named
Default value: $PWD.ProviderPath
Accept pipeline input: False
Accept wildcard characters: False
The minimum datetime to query.
Type: DateTime
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: [datetime]::MinValue
Accept pipeline input: False
Accept wildcard characters: False
The maximum datetime to query.
Type: DateTime
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: 8191-12-31
Accept pipeline input: False
Accept wildcard characters: False
The client IP address(es) to restrict the query to.
Type: String[]
Parameter Sets: (All)
Aliases: ClientIP
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The username to restrict the search to.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The HTTP (major) status to restrict the search to.
Type: Int32[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The HTTP method (GET or POST, &c) to restrict the search to.
Type: WebRequestMethod[]
Parameter Sets: (All)
Aliases:
Accepted values: Default, Get, Head, Post, Put, Delete, Trace, Options, Merge, Patch
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
A “like” pattern to match against the requested URI stem/path.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
A “like” pattern to match against the query string.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
A “like” pattern to match against the HTTP referrer.
Type: String
Parameter Sets: (All)
Aliases: RefererLike
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Iisw3c
Accept pipeline input: False
Accept wildcard characters: False
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
https://www.microsoft.com/download/details.aspx?id=24659
https://docs.microsoft.com/windows/win32/debug/system-error-codes
https://support.microsoft.com/help/943891/the-http-status-code-in-iis-7-0-iis-7-5-and-iis-8-0
https://docs.microsoft.com/dotnet/api/system.net.http.httpresponsemessage.statuscode
https://docs.microsoft.com/dotnet/api/system.componentmodel.win32exception