# Reading IIS logs with PowerShell

Today I was reading Twitter, as I am pretty addicted to technology news when Adam Bacon mentioned that he’s surprised that no one has rebuilt IIS Parser as pure PowerShell. While this is not entirely true, and some modules can do some parsing, I decided to try my luck. While doing it from scratch in PowerShell is possible, I opted to use an external C# library that does all the heavy lifting and is optimized for speed.

blog

04 Jun 2022 en

![Reading IIS logs with PowerShell](/wp-content/uploads/2022/06/Pasted-1.png)

[View images (2)](#pf-content-image-1-0)

Today I was reading Twitter, as I am pretty addicted to technology news when Adam Bacon mentioned that he's surprised that no one has rebuilt **IIS Parser** as pure **PowerShell**. While this is not entirely true, and some modules can do some parsing, I decided to try my luck. While doing it from scratch in **PowerShell** is possible, I opted to use an external **C# library** that does all the heavy lifting and is optimized for speed.

### 💡 Using IISParser to read IIS Logs

So after about 1 hour of playing with the library and creating a new **PowerShell** module called [**IISParser**](https://github.com/EvotecIT/IISParser), here we are. We now have an easy-to-use **PowerShell** function to **read IIS Logs**.

```generic
Get-IISParsedLog -FilePath "C:\Support\GitHub\IISParser\Ignore\u_ex220507.log" | Select-Object -First 5 | Format-Table
Get-IISParsedLog -FilePath "C:\Support\GitHub\IISParser\Ignore\u_ex220507.log" | Select-Object -First 5 -Last 5 | Format-Table
```

[!\[IIS Logs Parser in PowerShell\](/wp-content/uploads/2022/06/Pasted-1.png)](/wp-content/uploads/2022/06/Pasted-1.png)

Of course, when using **Format-Table,** we are not shown all the columns, but if we force the output using **Format-List,** we get all the **IIS properties**.

```generic
Get-IISParsedLog -FilePath "C:\Support\GitHub\IISParser\Ignore\u_ex220507.log" | Select-Object -First 5 -Last 5 | Format-List
```

[!\[IISParsers All Properties\](/wp-content/uploads/2022/06/Pasted-2.png)](/wp-content/uploads/2022/06/Pasted-2.png)

### 💡 Installing and updating IISParser

How do you install it? The easiest and most optimal way is to use **PowerShellGallery**. This will get you up and running in no time. Whenever there is an update, just run **Update-Module,** and you're done.

```generic
Install-Module IISParser
# Update-Module IISParser
```

However, if you're into code – want to see how everything is done, you can use **GitHub** sources. Please keep in mind that the **PowerShellGallery** version is optimized and better for production use. If you see any issues, bugs, or features that are missing, please make sure to submit them on **GitHub**.

- 💡 Code is published as a module on [PowerShellGallery](https://www.powershellgallery.com/packages/IISParser/)
- 💡 Issues should be reported on [GitHub](https://github.com/EvotecIT/IISParser/issues)
- 💡 Code is published on [GitHub](https://github.com/EvotecIT/IISParser)

## Related Projects

Projects that align with this post's tags, categories, and content.

[All projects](/projects/)

Matching projects...

[Back to Blog](/blog)

## Related posts

- [Check an API write after a PowerShell timeout](/blog/verify-uncertain-api-outcomes-powershell/)
- [Compose PDF reports and automate page workflows with PSWriteOffice](/blog/automate-pdf-reports-and-page-workflows-pswriteoffice/)
- [ImagePlayground: image automation that stays in PowerShell](/blog/imageplayground-powershell-image-automation/)

<!-- PowerForge markdown artifact sha256:7C7D395B6AD93E3A002A9732D99C51CE9DF89608F647B0DA9253387BA188B0AC -->
