Created
January 25, 2021 22:00
-
-
Save robderickson/0ff7c888efcf65a14283593f6954d650 to your computer and use it in GitHub Desktop.
For when you get tired of "send me a screenshot of the selected logging fields in IIS."
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-IisLogFieldConfig { | |
[CmdletBinding()] | |
param( | |
[string[]$ComputerName, | |
) | |
PROCESS { | |
foreach ($computer in $ComputerName) { | |
Invoke-Command -ComputerName $computer -ScriptBlock { | |
[System.Reflection.Assembly]::LoadFrom( "C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll" ) | Out-Null | |
$sites = (New-Object Microsoft.Web.Administration.ServerManager).Sites | |
foreach ($site in $sites) { | |
$CustomFields = $site.logfile.CustomLogFields | Select-Object -ExpandProperty SourceName | |
[pscustomobject]@{ | |
Name = $site.Name | |
LogExtFileFlags = $site.logfile.LogExtFileFlags | |
CustomLogFields = $CustomFields -join ', ' | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment