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

How to Build in a PSMethod to your PowerShell Code

0 51 0

In this video, PowerShell instructor Jason Yoder shows how to add Methods (PSMethod) to your code using free software that’s added into the PSObject. For instructor-led PowerShell courses, see our course schedule. Microsoft Windows PowerShell Training Download the Building Methods PowerShell script</a> used in this video. <# ╔══════════════════════════════════════════════════════════════════════════════╗ ║ ║ ║ Building Methods ║ ╟──────────────────────────────────────────────────────────────────────────────╢ … Continue reading How to Build in a PSMethod to your PowerShell Code

Creating Users and Managing Passwords in Microsoft Office 365

0 675 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    

Detailed Forensic Investigation of Malware Infections – April 21, 2015

4 630 5

How does an investigator hunt down and identify unknown malware? In this recording of our IT Security training webinar on April 21, 2015, Security expert Mike Danseglio (CISSP / CEH) performed several malware investigations on infected computers and identify symptoms, find root cause, and follow the leads to determine what’s happening. He demonstrated his preferred … Continue reading Detailed Forensic Investigation of Malware Infections – April 21, 2015

Write a Comment

Share your thoughts...

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