Skip to content

Latest commit

 

History

History

Transpose-Object

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Transpose-Object: Powershell script to transpose objects from columns to rows

Useful when the order displayed in a GridView (with Out-GridView) or in a CSV file (with Export-Csv) has to be rotated.

Since Technet Gallery will be closed, now here.

See Script Center version: Transpose-Object: Powershell script to transpose objects from columns to rows.

Description

Transpose-Object: Powershell script to transpose objects from columns to rows. Useful when the order displayed in a GridView (with Out-GridView) or in a CSV file (with Export-Csv) has to be rotated.

The function Transpose-Object works on an object passed to it through the pipeline and flips propertys of the object. It uses the name property as new property names (column headers) if it exists.

The information about the default view gets lost since new objects are created, you may have to place an limiting select statement before (see example below).

Examples

assuming Transpose-Object.ps1 is in the current directory

Show directory listing with a column instead of a row for every file/directory:

. .\Transpose-Object.ps1
dir | Transpose-Object | Out-GridView

Screenshot

Create a CSV file with a column instead of a row for every process:

. .\Transpose-Object.ps1
ps | Transpose-Object | Export-Csv Processes.csv -Delimiter ';' -NoTypeInformation

Screenshot2

Use and transpose only the default view properties:

. .\Transpose-Object.ps1
Get-ChildItem | Select-Object Mode, LastWriteTime, Length, Name | Transpose-Object

Version: 1.2 - values of 0, $FALSE or "" not longer identified as $NULL

Creation Date: 20/03/2023