Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Uri does not contain a method named 'new'

[System.Uri]::new('http://www.stackoverflow.com') is failing with error message

[System.Uri] does not contain a method named 'new'

however I am able to find this method on another box. and runs fine.

How to find if there is difference between System object loaded under PowerShell

like image 279
Abhay Avatar asked Apr 19 '17 07:04

Abhay


1 Answers

You need Powershell 5 or higher to use the .ctor of a .NET class. In older versions of Powershell you'll have to use New-Object to do this.

like image 85
bluuf Avatar answered Oct 26 '22 17:10

bluuf