Converting the FileSystemObject's Skip Method

Definition: Skip over the first n number of characters when reading a line from a text file.


Use Get-Content and the -totalcount paramenter to retrieve the first line from the text file. To skip the first 5 characters, start with item 5 (the sixth item in the array) and read the rest of the line up to the length of the array.

$a = Get-Content test.txt -totalcount 1

Keep in mind that this code returns an array rather than a string. Also note that in Windows PowerShell 1.0, the -totalcount parameter works with only one line.

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