--- external help file: PSScriptTools-help.xml Module Name: PSScriptTools online version: http://bit.ly/31VAujZ schema: 2.0.0 --- # ConvertFrom-Text ## SYNOPSIS Convert structured text to objects. ## SYNTAX ### File (Default) ```yaml ConvertFrom-Text [-Pattern] [-Path] [-TypeName ] [-NoProgress] [] ``` ### Inputobject ```yaml ConvertFrom-Text [-Pattern] [-InputObject] [-TypeName ] [-NoProgress] [] ``` ## DESCRIPTION This command will take structured text such as from a log file and convert it to objects that you can use in the PowerShell pipeline. You can specify the path to a text file, or pipe content directly into this command. The piped content could even be output from command-line tools. You have to specify a regular expression pattern that uses named captures. The names will become property names in the custom objects. The command will write a generic custom object to the pipeline. However, you can specify a custom type name. You might want to do this if you have your own format ps1xml file and want to handle formatting through that file. ## EXAMPLES ### EXAMPLE 1 ```powershell PS C:\> $b = "(?\d{2}-\d{2}-\d{4}\s\d{2}:\d{2}).*(?\d+),\s+(?.*):\s+(?\w+),\s+(?(\w+\\)*\w+\.\w+)" PS C:\> ConvertFrom-Text -pattern $b -path C:\windows\DtcInstall.log Date : 10-18-2020 10:49 Error : 0 Step : CMsdtcUpgradePlugin::PostApply Action : Enter Path : com\complus\dtc\dtc\msdtcstp\msdtcplugin.cpp Date : 10-18-2020 10:49 Error : 0 Step : CMsdtcUpgradePlugin::PostApply Action : Exit Path : com\complus\dtc\dtc\msdtcstp\msdtcplugin.cpp ... ``` The first command creates a variable to hold the regular expression pattern that defines named captures for content in the DtcInstall.log. The second line runs the command using the pattern and the log file. ### EXAMPLE 2 ```powershell PS C:\> $wu = "(?\d{4}-\d{2}-\d{2})\s+(?