# IIS 7.5 w3c logging fields

**URL:** <https://forums.powershell.org/t/iis-7-5-w3c-logging-fields/1401>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/iis-7-5-w3c-logging-fields/1401 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/iis-7-5-w3c-logging-fields/1401/1 "2011-12-31T18:30:00Z")

</div>

by qvantas at 2013-01-07 12:33:43

> Hi all!  
> Is it possible to use powershell to change the w3c logging fields?  
> I only want a few of these fields to be checked.  
>   
> Cheers!  
>   
> //Johan

by JasonHelmick at 2013-01-15 12:20:44

> Hey Johan!  
>   
> Here’s one way to do it using Set-WebConfigurationProperty cmdlet from the WebAdministration module. The -Value parameter takes a single string with the options you want enabled separated by comma’s. This is not a powershell array, so make sure its surrounded in quotes. Below I enabled only Date, Time and the ClientIP for the log.  
>   
> Set-WebConfigurationProperty -Filter System.Applicationhost/Sites/SiteDefaults/logfile -Name LogExtFileFlags -Value "Date,Time,ClientIP"  
>   
> To a the current list of enabled items:  
>   
> Get-WebConfiguration -filter system.applicationhost/sites/sitedefaults/logfile | Select-Object -ExpandProperty logExtFileFlags   
>   
> Hope this helps!  
>   
> Jason

by qvantas at 2013-01-17 03:04:22

> Hi Jason!  
> This works great when im logged on to the server.  
> Is it possible to deploy this on remote servers? Have a text file with alot of webservers.  
>   
> Cheers,  
>   
> Johan

by JasonHelmick at 2013-01-17 06:05:50

> Sure! But you need to have PowerShell Remoting enabled. So, if you do just use the Invoke-Commmand…  
> Invoke-Command -ComputerName Web1, Web2 {set-WebConffigurationProperty blah blah blah }  
>   
> If you don’t, take a look at Don’s ebook on turning it on. "Secrets of PowerShell Remoting" [http://powershellbooks.com](http://powershellbooks.com)  
>   
> Cheers!

by qvantas at 2013-01-17 06:39:52

> Hi Jason!  
> Thanks for ur help 🙂  
> Have enabled "psremoting" but i still dont get it to work ☹  
> Any ideas?  
>   
> PS H:&gt; Import-Module webadministration  
> PS H:&gt; invoke-command -computername servername {Set-WebConfigurationProperty -Filter System.Applicationhost/Sites/  
> SiteDefaults/logfile -Name LogExtFileFlags -Value "Date,Time,ClientIP"}  
>   
> The term ‘Set-WebConfigurationProperty’ is not recognized as the name of a cmdlet, function, script file, or operable p  
> rogram. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.  
> + CategoryInfo : ObjectNotFound: (Set-WebConfigurationProperty:String) , CommandNotFoundException  
> + FullyQualifiedErrorId : CommandNotFoundException

by JasonHelmick at 2013-01-17 06:43:49

> 😉  
>   
> Sure! You really close to getting it to work…here’s the issue…  
>   
> You need to import the module on the remote computer…do this…  
>   
> Invoke-Command -ComputerName server {Import-Module WebAdministration}  
>   
> Then   
>   
> Invoke-Command -ComputerName server {Set-webConfigurationProperty blah blah}  
>   
> Did this help?  
>   
> Jason

by qvantas at 2013-01-17 06:54:18

> No ☹ Same error  
> i can do things like invoke-command -computername {get-process)  
>   
> Regards  
> Johan

by ArtB0514 at 2013-01-17 11:23:52

> If you want to invoke several commands on a remote computer and remember context and values between the commands then you need to set up a PSSession and run the commands in it.  
>   
> `$MySession = New-PSSession -ComputerName serverInvoke-Command -Session $MySession -ScriptBlock {Import-Module WebAdministration}Invoke-Command -Session $MySession -ScriptBlock {Set-webConfigurationProperty blah blah}Remove-PSSession $MySession`  
>   
> Or you need to put all the commands that you want to run into a single scriptblock.  
>   
> `Invoke-Command -ComputerName server -ScriptBlock { Import-Module WebAdministration Set-webConfigurationProperty blah blah}`

by JasonHelmick at 2013-01-18 09:08:52

> ArtB0514 - Great contribution! thank you!  
>   
> Johan - Let me ask a really dumb question…is IIS installed on the remote computers? - and if so, what version of IIS are you running?  
>   
> So, Enter-PsSession -ComputerName RemoteServer  
>   
> then  
>   
> Get-Module _web_  
>   
> Is there a webadministration module listed?

by qvantas at 2013-01-21 00:03:08

> Hi admins!!  
> Thanks for your reply’s, really appreciate it 🙂  
> Weekend is over and im back to my computers…   
>   
> PS C:&gt; Invoke-Command -ComputerName Servername {import-module webadministration | Set-WebConfigurationProperty -Filter System.Applicationhost/Sites/SiteDefaults/logfile -Name LogExtFileFlags -Value "Date,Time,ClientIP"}  
> The term ‘Set-WebConfigurationProperty’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a pa  
> th was included, verify that the path is correct and try again.  
> + CategoryInfo : ObjectNotFound: (Set-WebConfigurationProperty:String) , CommandNotFoundException  
> + FullyQualifiedErrorId : CommandNotFoundException  
> + PSComputerName : Servername  
>   
>   
> But this works:   
> PS C:&gt; $MySession = New-PSSession -ComputerName Servername  
> Invoke-Command -Session $MySession -ScriptBlock {Import-Module WebAdministration}  
> Invoke-Command -Session $MySession -ScriptBlock {Set-WebConfigurationProperty -Filter System.Applicationhost/Sites/SiteDefaults/logfile -Name LogExtFileFlags -Value "Date,Time,ClientIP"}  
> Remove-PSSession $MySession  
>   
> But this is only a connection to one server, i now have to figure out how this can be run on multiple servers.  
>   
> Cheers,  
>   
> Johan

by qvantas at 2013-01-21 01:28:58

> hi!  
>   
> i think ive nailed it 🙂  
>   
> $server = get-content C:\skydrive\scripts\test.txt  
> $MySession = New-PSSession -ComputerName $server  
> ForEach ($srv in $server)  
> {Invoke-Command -Session $MySession -ScriptBlock {Import-Module WebAdministration}  
> Invoke-Command -Session $MySession -ScriptBlock {Set-WebConfigurationProperty -Filter System.Applicationhost/Sites/SiteDefaults/logfile -Name LogExtFileFlags -Value "Date,Time,ClientIP"}  
> }  
> Remove-PSSession $MySession  
>   
> Thanks!!

by JasonHelmick at 2013-01-21 07:12:42

> Hey Johan!  
>   
> the -ComputerName of New-PsSession and Invoke-Command accepts multiple values seperated by comma’s…so…as an example  
>   
> New-PsSession -ComputerName server1, Server2, Server3  
>   
> Jason

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:58pm UTC](https://forums.powershell.org/t/iis-7-5-w3c-logging-fields/1401/2 "2024-05-16T20:58:14Z")

</div>


