# Formatting output get-windowsfeature for a report

**URL:** <https://forums.powershell.org/t/formatting-output-get-windowsfeature-for-a-report/16775>\
**Category:** PowerShell Help\
**Created:** [June 9, 2021, 9:37am UTC](https://forums.powershell.org/t/formatting-output-get-windowsfeature-for-a-report/16775 "2021-06-09T09:37:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![miguel\_gonz](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/miguel_gonz/32/1391_2.png) [@miguel\_gonz](https://forums.powershell.org/u/miguel_gonz)\
**Post date:** [June 9, 2021, 9:37am UTC](https://forums.powershell.org/t/formatting-output-get-windowsfeature-for-a-report/16775/1 "2021-06-09T09:37:21Z")

</div>

Hi,

I am trying to create a table in a report in CSV that I can copy and paste to a Word table for a report of what is installed on a machine in terms of roles and features.

I see that without no selection of any property I get a nice indented output like this one:

```auto
Get-WindowsFeature | Where-Object {$_. installstate -eq "installed"}

Display Name Name Install State
------------ ---- -------------
[X] Servicios de archivos y almacenamiento FileAndStorage-Services Installed
  [X] Servicios de almacenamiento Storage-Services Installed
[X] Características de .NET Framework 4.6 NET-Framework-45-Fea... Installed
  [X] .NET Framework 4.6 NET-Framework-45-Core Installed
  [X] Servicios WCF NET-WCF-Services45 Installed
      [X] Uso compartido de puertos TCP NET-WCF-TCP-PortShar... Installed
[X] Características de Windows Defender Windows-Defender-Fea... Installed
  [X] Windows Defender Windows-Defender Installed
[X] Compatibilidad con el protocolo para compartir a... FS-SMB1 Installed
[X] Compatibilidad con WoW64 WoW64-Support Installed
[X] Windows PowerShell PowerShellRoot Installed
  [X] Windows PowerShell 5.1 PowerShell Installed

```

If I select the property displayname I lose the and the indentation of the hierarchy. In my report I want to show that hierarchy through the indentation (if possible replacing with tabs).

How can I achieve that?

---

<div class="post-metadata">

**Author:** ![kvprasoon](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/kvprasoon/32/4449_2.png) [@kvprasoon](https://forums.powershell.org/u/kvprasoon)\
**Post date:** [June 9, 2021, 10:19am UTC](https://forums.powershell.org/t/formatting-output-get-windowsfeature-for-a-report/16775/2 "2021-06-09T10:19:04Z")

</div>

@miguel_gonz Welcome to [PowerShell.org](http://PowerShell.org) forums.

IMO, these checkboxes are not directly given by `Get-windowsFeature` but added by formatting subsystem and cannot be made available directly to a csv/excel file. Since you are already filtering out for only installed, its obvious that all the items in the CSV are installed. So a special indication is actually not required.

You can create a new property based on installed status and this new property can be a column in your csv. You can Calculate a property for that.

```auto
Get-WindowsFeature | Where-Object {$_. installstate -eq "installed"} |
Select-Object -Property Name, 'Display Name', @{E='Yes';L='Status'}

```

---

<div class="post-metadata">

**Author:** ![miguel\_gonz](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/miguel_gonz/32/1391_2.png) [@miguel\_gonz](https://forums.powershell.org/u/miguel_gonz)\
**Post date:** [June 9, 2021, 10:54am UTC](https://forums.powershell.org/t/formatting-output-get-windowsfeature-for-a-report/16775/3 "2021-06-09T10:54:39Z")

</div>

Thanks for the prompt reply. I think I haven´t myself understood.

I want to display only “Display Name” property with indentation (grouped exactly as shown before), so something like this:

```auto
 Servicios de archivos y almacenamiento              
   Servicios de almacenamiento                     
 Características de .NET Framework 4.6               
   .NET Framework 4.6                              
   Servicios WCF                                   
       Uso compartido de puertos TCP              
 Características de Windows Defender                 
   Windows Defender                                
 Compatibilidad con el protocolo para compartir a... 
 Compatibilidad con WoW64                            
Windows PowerShell                                  
   Windows PowerShell 5.1 

```

---

<div class="post-metadata">

**Author:** ![kvprasoon](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/kvprasoon/32/4449_2.png) [@kvprasoon](https://forums.powershell.org/u/kvprasoon)\
**Post date:** [June 9, 2021, 1:14pm UTC](https://forums.powershell.org/t/formatting-output-get-windowsfeature-for-a-report/16775/4 "2021-06-09T13:14:40Z")

</div>

![image](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/5/5b16e97c15b88a790582a6c297fb87e9b73cb78a.png)

Even the spaces are added by formatting subsystem.

Below is a post I wrote few years back on it if you want to understand it more.

[Learn-PowerShel l| Rule the World Using A OneLiner: Hidden Formatting in PowerShell (viapowershell.com)](http://www.viapowershell.com/2016/06/hidden-formatting.html)

---

<div class="post-metadata">

**Author:** ![miguel\_gonz](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/miguel_gonz/32/1391_2.png) [@miguel\_gonz](https://forums.powershell.org/u/miguel_gonz)\
**Post date:** [June 9, 2021, 3:32pm UTC](https://forums.powershell.org/t/formatting-output-get-windowsfeature-for-a-report/16775/5 "2021-06-09T15:32:31Z")

</div>

Many thanks for pointing me to the right direction.

For the sake of completeness I share a basic code I used following the info you shared:

```auto
$roles= Get-WindowsFeature | Where-Object {$_. installstate -eq "installed"}

foreach ($element in $roles) {
	$indent=""
	for ($i=$element.Depth; $i -gt 1; $i--)
	{ 
 	   $indent += " "
        }
	$indent+ $element.DisplayName
}

```

---

<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:24pm UTC](https://forums.powershell.org/t/formatting-output-get-windowsfeature-for-a-report/16775/6 "2024-05-16T20:24:14Z")

</div>


