# Solving typo problems with Fuzzy Search in PSWriteHTML

One of the everyday use cases with PSWriteHTML is to create a simple view of PowerShell data in a table. While PowerShell comes with a built-in cmdlet ConvertTo-Html, it’s basic in its functionality. It makes an HTML representation of PowerShell data, but it brings no CSS, JavaScript, or other functionality. While for some use cases, it’s enough, the other times, you need to make an effort to make it usable.

blog

29 Nov 2021 en

![Solving typo problems with Fuzzy Search in PSWriteHTML](/wp-content/uploads/2021/11/img_61a36ca52a61b.png)

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

One of the everyday use cases with [**PSWriteHTML**](https://github.com/EvotecIT/PSWriteHTML) is to create a simple view of PowerShell data in a table. While **PowerShell** comes with a built-in cmdlet **ConvertTo-Html**, it's basic in its functionality. It makes an **HTML** representation of **PowerShell** data, but it brings no CSS, JavaScript, or other functionality. While for some use cases, it's enough, the other times, you need to make an effort to make it usable.

### 💡 ConvertTo-HTML vs Out-HtmlView vs New-HTMLTable

This is where the **PSWriteHTML** shines. With just a little effort, you get all sorts of ways to represent your PowerShell data with tables, charts, diagrams, gages, or even maps if there's a need for that. But one command I use in every single report **New-HTMLTable** and **Out-HTMLView**. The difference between the two is that **New-HTMLTable** acts a bit like **ConvertTo-HTML,** where it provides you a part of the HTML page where you can insert it into the **New-HTML** object. **Out-HTMLView** acts as an instant reporting tool, where it doesn't require any other things to do its magic. I already wrote a ton of blog posts on my website about **PSWriteHTML**, and if you want to find out more about those – please search my website, and you won't be disappointed. With the standard approach, you would use something like the code below, and then you would save it to an HTML file and get sort of basic-looking HTML.

```powershell
Get-ADUser -Filter * | Select-object -First 1 | ConvertTo-Html
```

[!\[Plain ConvertTo-Html output showing a basic PowerShell user table\](/wp-content/uploads/2021/11/img_61a36ca52a61b.png)](/wp-content/uploads/2021/11/img_61a36ca52a61b.png)[!\[Browser view of the same table with default styling\](/wp-content/uploads/2021/11/img_61a36c896c9e6.png)](/wp-content/uploads/2021/11/img_61a36c896c9e6.png)

The three steps from above can be achieved with just one step using **PSWriteHTML**, and the result is much more user-friendly.

```powershell
Get-ADUser -Filter * | Out-HTMLView
```

[!\[Out-HTMLView output showing a formatted table in the browser\](/wp-content/uploads/2021/11/img_61a36d01c133c.png)](/wp-content/uploads/2021/11/img_61a36d01c133c.png)[!\[Formatted Out-HTMLView page with built-in controls and search\](/wp-content/uploads/2021/11/img_61a36e9e665d1.png)](/wp-content/uploads/2021/11/img_61a36e9e665d1.png)

By default, you get the ability to export to **Excel**, **CSV**, and **pdf**. You also get a standard search and search builder, which gives you a custom way of searching thru the data. If you're interested in those options, you can find them in blog posts that I have already published. Today I wanted to talk about one new option, which is called **Fuzzy Search**.

> In computer science, approximate string matching (often colloquially referred to as fuzzy string searching) is the technique of finding strings that match a pattern approximately (rather than exactly).

What does this mean in practice? If you're looking for **Przemyslaw** but type **przemlaw** in a regular search, you would get no results. The same goes for typing **krgbt** when you're looking for **krbtgt**. With just a simple switch you can now forget about typo problems!

[!\[Fuzzy search enabled to match a typo in the search box\](/wp-content/uploads/2021/11/img_61a372c708b45.png)](/wp-content/uploads/2021/11/img_61a372c708b45.png)

As you can see, there are two new switches. The first one, **FuzzySearch**, enables fuzzy search, and the other one allows you to switch between fuzzy search and exact search within the interface. It's also possible to use **FuzzySearchSmartToggle**, which will enable FuzzySearch regardless of whether you use the FuzzySearch switch or not.

```powershell
get-aduser -Filter * | Out-HtmlView -FuzzySearchSmartToggle
```

```powershell
get-aduser -Filter * | Out-HtmlView -FuzzySearch -FuzzySearchSmartToggle
```

Both of those will give you the same result.

[!\[Table toolbar showing the fuzzy search and exact search toggle\](/wp-content/uploads/2021/11/img_61a375511109d.png)](/wp-content/uploads/2021/11/img_61a375511109d.png)[!\[Example table demonstrating switching between fuzzy and exact search\](/wp-content/uploads/2021/11/img_61a3860cc82e0.png)](/wp-content/uploads/2021/11/img_61a3860cc82e0.png)

If you use the toggle in the right top corner, you get the ability to switch between standard and fuzzy options. This can be useful if a vague search will show a bit too much while you wanted an exact search. If you skip the **FuzzySearchSmartToggle** switch, you won't have an option to toggle between the two.

### 💡 Using New-HTMLTable with FuzzySearch

Of course, Out-HTMLView is just a cmdlet to play quick reporting. Same fuzzy search is available within New-HTMLTable where you can apply it as you want

```powershell
$Users = Get-ADUser -Filter * -Properties LastLogonDate, PasswordLastSet | Select-Object -First 6
New-HTML {
    New-HTMLTable -DataTable $Users -Title 'Table with Users' -HideFooter -PagingLength 5 -FuzzySearch {
        New-TableAlphabetSearch -ColumnName 'Name' -CaseSensitive -AddNumbers
    } -FuzzySearchSmartToggle

    New-HTMLTable -DataTable $Users -Title 'Table with Users' -HideFooter -PagingLength 5 {
        New-TableAlphabetSearch -ColumnName 'Name' -CaseSensitive -AddNumbers
    }
} -ShowHTML -FilePath "$PSScriptRoot\Example-FuzzySearch.html" -Online
```

[!\[Two tables comparing fuzzy search enabled and disabled\](/wp-content/uploads/2021/11/img_61a50ec39cd70.png)](/wp-content/uploads/2021/11/img_61a50ec39cd70.png)

As you can see above, I've only enabled **FuzzySearch** for one table (and with Alphabet Search as well). The other one has it disabled. I do hope this new feature will bring you as much joy as it did to me!

```powershell
Get-Process | Out-htmlview -First 5 -FuzzySearchSmartToggle
```

[!\[Out-HTMLView results for the first five processes with fuzzy search toggle\](/wp-content/uploads/2021/11/img_61a51354284f5.png)](/wp-content/uploads/2021/11/img_61a51354284f5.png)

### 💡 Earlier resources for PSWriteHTML, Dashimo, Statusimo or Emailimo as PowerShell Modules

If you don't know [**PSWriteHTML**](https://github.com/EvotecIT/PSWriteHTML), please read those articles below to understand how you can use its power to fulfill your goals. All the topics described above are just a small part of what [**PSWriteHTML**](https://github.com/EvotecIT/PSWriteHTML) can do.

- [Meet Statusimo – PowerShell generated Status Page](https://evotec.xyz/meet-statusimo-powershell-generated-status-page/)
- [Meet Dashimo – PowerShell Generated Dashboard](https://evotec.xyz/meet-dashimo-powershell-generated-dashboard/)
- [Dashimo – Easy Table Conditional Formatting and more](https://evotec.xyz/dashimo-easy-table-conditional-formatting-and-more/)
- [Out-HtmlView – HTML alternative to Out-GridView](https://evotec.xyz/out-htmlview-html-alternative-to-out-gridview/)
- [Meet Emailimo – New way to send pretty emails with PowerShell](https://evotec.xyz/meet-emailimo-new-way-to-send-pretty-emails-with-powershell/)
- [All your HTML Tables are belong to us](https://evotec.xyz/all-your-html-tables-are-belong-to-us/)
- [Sending HTML emails with PowerShell and zero HTML knowledge required](https://evotec.xyz/sending-html-emails-with-powershell-and-zero-html-knowledge-required/)
- [Dashimo (PSWriteHTML) – Charting, Icons, and few other changes](https://evotec.xyz/dashimo-pswritehtml-charting-icons-and-few-other-changes/)
- [Working with HTML in PowerShell just got better](https://evotec.xyz/working-with-html-in-powershell-just-got-better/)
- [Comparing two or more objects visually in PowerShell (cross-platform)](https://evotec.xyz/comparing-two-or-more-objects-visually-in-powershell-cross-platform/)
- [Easy way to create diagrams using PowerShell and PSWriteHTML](https://evotec.xyz/easy-way-to-create-diagrams-using-powershell-and-pswritehtml/)
- [Nested Tabs, Diagram Updates, Diagram Events, Calendar Object, and more in PSWriteHTML](https://evotec.xyz/nested-tabs-diagram-updates-diagram-events-calendar-object-and-more-in-pswritehtml/)
- [Emailimo merged into PSWriteHTML, IE support, and no dependencies](https://evotec.xyz/emailimo-merged-into-pswritehtml-ie-support-and-no-dependencies/)
- [Active Directory DHCP Report to HTML or EMAIL with zero HTML knowledge](https://evotec.xyz/active-directory-dhcp-report-to-html-or-email-with-zero-html-knowledge/)
- [Creating Office 365 Migration Diagram with PowerShell](https://evotec.xyz/creating-office-365-migration-diagram-with-powershell/)
- [Advanced HTML reporting using PowerShell](https://evotec.xyz/advanced-html-reporting-using-powershell/)

To get it up and running, just install it from **PowerShellGallery** and you're good.

```powershell
Install-Module PSWriteHTML -Force
```

While blog posts focus on **PSWriteHTML,** many other blog posts show different features that utilize **PSWriteHTML** to fulfill their goal.

## Related Projects

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

[All projects](/projects/)

Matching projects...

[Back to Blog](/blog)

## Related posts

- [Advanced HTML reporting using PowerShell](/blog/advanced-html-reporting-using-powershell/)
- [Dashimo (PSWriteHTML) – Charting, Icons and few other changes](/blog/dashimo-pswritehtml-charting-icons-and-few-other-changes/)
- [Enhanced Dashboards with PSWriteHTML – Introducing InfoCards and Density Options](/blog/enhanced-dashboards-with-pswritehtml-introducing-infocards-and-density-options/)

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