Forum Discussion
Yuansheng Zhang
Jan 05, 2021Copper Contributor
Powershell 7 compatible to Powershell 5?
I got many issues when I tried to migrate the scripts developed in PS5 to PS7, such as Form, DataGridView and so on. For a simple example, I have the following code working fine in PS 5.1.18362.1171...
boneyfrancis
Jan 05, 2021Iron Contributor
Hi Yuansheng Zhang ,
I verified your code on PS5 and PS7, and confirmed that "$p" lists ParsedHtml in PS5 but not in PS7; this is why you're getting the null-valued expression error because $t is looking for $p.ParsedHtml.
Per https://docs.microsoft.com/en-us/powershell/scripting/whats-new/breaking-changes-ps6?view=powershell-7.1:
The underlying .NET API of the Web Cmdlets has been changed to System.Net.Http.HttpClient. This change provides many benefits. However, this change along with a lack of interoperability with Internet Explorer have resulted in several breaking changes within Invoke-WebRequest and Invoke-RestMethod.
- Invoke-WebRequest now supports basic HTML Parsing only. Invoke-WebRequest always returns aBasicHtmlWebResponseObject object. The ParsedHtml and Forms properties have been removed.
More discussion on this limitation: https://github.com/PowerShell/PowerShell/issues/2867