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

1 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

Agile Methodology in Project Management

0 185 0

In this video, you will gain an understanding of Agile and Scrum Master Certification terminologies and concepts to help you make better decisions in your Project Management capabilities. Whether you’re a developer looking to obtain an Agile or Scrum Master Certification, or you’re a Project Manager/Product Owner who is attempting to get your product or … Continue reading Agile Methodology in Project Management

An Overview of Office 365 – Administration Portal and Admin Center

0 960 3

This is part 1 of our 5-part Office 365 free training course. In this Office 365 training video, instructor Spike Xavier introduces some of the most popular services found in Microsoft Office 365 including the Admin Portal and Admin Center. For instructor-led Office 365 training classes, see our course schedule: Spike Xavier SharePoint Instructor – … Continue reading An Overview of Office 365 – Administration Portal and Admin Center

Creating Users and Managing Passwords in Microsoft Office 365

0 809 5

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    

Write a Comment

Share your thoughts...

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