Skip to content

Instantly share code, notes, and snippets.

@robderickson
Created January 25, 2021 22:00
Show Gist options
  • Save robderickson/0ff7c888efcf65a14283593f6954d650 to your computer and use it in GitHub Desktop.
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."
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