# 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 pl

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

[Zobacz obrazy (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)

## Powiązane projekty

Projekty powiązane z tagami, kategoriami i treścią tego wpisu.

[Wszystkie projekty](/projekty/)

Trwa dopasowywanie projektów...

[Powrót do bloga](/blog/)

## Powiązane wpisy

- [Check an API write after a PowerShell timeout](/blog/verify-uncertain-api-outcomes-powershell/)
- [Inspect and convert mixed Office archives with PSWriteOffice](/blog/inspect-and-convert-mixed-office-archives-pswriteoffice/)
- [Compose PDF reports and automate page workflows with PSWriteOffice](/blog/automate-pdf-reports-and-page-workflows-pswriteoffice/)

<!-- PowerForge markdown artifact sha256:A18532A06EBECC1BBD29CA09ACE567C39CF38D730DF54041C07492B6E42CFC4D -->
