How to change the IIS log contents with PowerShell
How to change the IIS log contents with PowerShell
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.
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
You May Also Like
IIS, IIS logs, Powershell, PowerShell Remoting, W3C, WebConfigurationProperty
A Simple Introduction to Cisco CML2
0 3703 0Mark Jacob, Cisco Instructor, presents an introduction to Cisco Modeling Labs 2.0 or CML2.0, an upgrade to Cisco’s VIRL Personal Edition. Mark demonstrates Terminal Emulator access to console, as well as console access from within the CML2.0 product. Hello, I’m Mark Jacob, a Cisco Instructor and Network Instructor at Interface Technical Training. I’ve been using … Continue reading A Simple Introduction to Cisco CML2
How to Build in a PSMethod to your PowerShell Code
0 68 0In 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
How to use the PowerShell Script Analyzer to Clean Up Your Code
0 1229 2In this video, PowerShell instructor Jason Yoder demonstrates how you can use the PowerShell Script Analyzer to help you format your code to best-practices. For instructor-led PowerShell training classes, see our course schedule: Microsoft Windows PowerShell Training Download the PowerShell Analyzer scripts used in this video. <# ╔══════════════════════════════════════════════════════════════════════════════╗ ║ ║ ║ PowerShell Script Analyzer ║ … Continue reading How to use the PowerShell Script Analyzer to Clean Up Your Code