How to change the IIS log contents with PowerShell

Home > Blogs > PowerShell > How to change the IIS log contents with PowerShell

How to change the IIS log contents with PowerShell

Like This Blog 0 Jason Helmick
Added by March 1, 2013

Ever want to change the type of information contained in your IIS logs?  While the default settings are useful, there’s much more data you could be collecting.  Graphical you can do this on a per server bases in the “Logging” feature and selecting the “Select Fields” option.

W3C Logging Fields How to change the IIS log contents with PowerShell

My problem is that I want to set this on several web servers. You can do this using PowerShell Remoting and the Set-WebConfigurationProperty cmdlet from the WebAdministration module.

To get a list of the current fields:

PS> $Session=New-PsSession –ComputerName Web1, Web2, Web3

PS> Invoke-Command –Session $Session {

Get-WebConfiguration –filter system.applicationhost/sites/sitedefaults/logfile |

Select-Object -ExpandProperty logExtFileFlags }

To change the list using the same Remoting session:

Invoke-Command –Session $session {

Set-WebConfigurationProperty -Filter System.Applicationhost/Sites/SiteDefaults/logfile -Name LogExtFileFlags -Value “Date,Time,ClientIP”}

Have fun!

Knowledge is PowerShell

Jason

 

Jason Helmick
Director of PowerShell Technologies
Interface Technical Training

Videos You May Like

Creating Users and Managing Passwords in Microsoft Office 365

0 723 3

In this Office 365 training video, instructor Spike Xavier demonstrates how to create users and manage passwords in Office 365.   For instructor-led Office 365 training classes, see our course schedulle: Spike Xavier SharePoint Instructor – Interface Technical Training Phoenix, AZ 20347: Enabling and Managing Office 365    

Using Navigation Controls in a Collaboration Site in SharePoint

0 346 1

In this SharePoint training video, I want to talk about the Navigation Controls in SharePoint. They tend to fall into two kind of different categories; one with the navigation controls in a typical Collaboration Site such as a Team Site or a Project Site. These are Sites that are based on the Team Site Template … Continue reading Using Navigation Controls in a Collaboration Site in SharePoint

Windows 10 Features and Navigation – December 1, 2015

0 126 1

In this recorded Windows 10 webinar from December 1,2015, Windows Instructor Steve Fullmer presents the navigation and some of the new features associated with Windows 10 including Sysinternals Tools for Windows Client, Windows core concepts, exploring Process Explorer as well as some of the features that are not yet ready for prime time but will … Continue reading Windows 10 Features and Navigation – December 1, 2015

Write a Comment

Share your thoughts...

Please fill out the comment form below to post a reply.