Reputation: 55
I have read here that when we read in the contents of .txt
file using the get-content
cmdlet into a variable, it is saved as an Array:
When Get-Content reads a text file and stashes the contents in a variable, the data is stored as an array, with each line in the file (determined by the presence of a carriage return-linefeed character) representing a single item in the array.
I read in the contents of the text file using get-content
, and 4
lines were printed to the powershell console.
Then I read in the contents of the same file into a variable ips
, and then used the ips.length
as well as ips.count
, 7
was printed out.
What am I missing?
Upvotes: 0
Views: 921
Reputation: 4603
There is a blank line at the top and two at the bottom of your content. These, plus the four lines of content = count/length 7
Upvotes: 1