Can someone help me understand why the following three lines in a PS Studio

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 3 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
DanielJohnson
Posts: 6
Last visit: Tue Feb 02, 2021 11:54 pm

Can someone help me understand why the following three lines in a PS Studio

Post by DanielJohnson »

Can someone help me understand why the following three lines in a PS Studio script do not work. But, they do work when run in PS ISE or as a PS command-line?

$TextFile = "C:\TextList.txt" #There are 85 lines of text in this file
$FileTextLines = Get-Content -Path $TextFile
$LineCT = $FileTextLines.Count

When I run this script in PS Studio $LineCT returns 0; whereas, when I run it in PS ISE it returns 85. Also, when I mouse over the $FileTextLines variable during a PS Studio debug session it doesn't show any data in the object at all.

I also noticed that when I use the Readline() as an alternative approach to the problem I get an empty string back, as well. But, when I step through the Readline() loop in a debug session it will read and populate the variable properly. Only when executed without stopping it returns an empty string. Strange.

Appreciate any help with this issue. This is a day-old install of the newly purchase PS Studio. Could this be a bug in PS Studio, or are the execution environments different between PS Studio and PS ISE?
This topic is 3 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked