Export (0) Print
Expand All
Expand Minimize

Converting the FileSystemObject's Column Property

Windows PowerShell

Definition: When reading through a line in a text file one or more characters at a time, Column contains the current character position within the line.


PowerShell reads file contents into an array, so the character position can be determined by the array item.

This example returns the character at column 4 (item 3 in the array):

$b = "a string"

An example that more closely maps to the intent of Column would be an example that reads through a line in the text file. Again, the column will be the array index plus 1 (because arrays start at 0).

$a = get-content c:\scripts\test.txt -totalcount 1
for ($i = 0; $i -lt $a.length; $i++)
    "Column is " + ($i + 1)

Note that this solution works only on a single line at a time.

See conversions of other FileSystemObject methods and properties.
Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft