.NET formatted file
CLI aka Common Language Infrastructure is an XML-based representation of an object or objects and stored in a file. When importing, the .Net object structure is preserved
$object = Import-Clixml -Path ".\example.xml"List the data types of an object
$object | Get-Member | select -ExpandProperty TypeName -UniqueList the members of an object
$object | Get-MemberCount the elements of the object
$object.CountPlain text file
Import all lines from a plaintext file
$lines = Get-Content -Path ".\example.txt"Import only a specific line or range of lines from a plaintext file:
$line26 = (Get-Content -Path ".\example.txt")[25]
$line23til26 = (Get-Content -Path ".\example.txt")[22..25]-TotalCountspeeds up the commands by only loading the first 26 lines.
$line26 = (Get-Content -Path ".\example.txt" -TotalCount 26)[25]
$line23til26 = (Get-Content -Path ".\example.txt" -TotalCount 26)[22..25]Count the number of lines:
$lines.CountImport data out of plaintext files
Sources:
Related:
Tags: Handle data - Handle, Import, Export, Filter and RegEx query objects in PowerShell