I tried doing:
Add-Type -AssemblyName System.Net
Add-Type -Path "C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Net.dll"
[System.Reflection.Assembly]::LoadWithPartialName("system.net")
add-type -path "C:\Windows\assembly\GAC_MSIL\System.Net\3.5.0.0__b03f5f7f11d50a3a\System.Net.dll"
All of those appear to succeed and do not produce an error. Yet, [net]
(or [System.Net]
) still gives
Unable to find type [net]: make sure that the assembly containing this type is loaded.
Is there no way to use these classes from Powershell, or how do I then call members? I don't know if system.net is actually going to have what I want anyway, but I'm trying to generally figure out how to use .Net classes in Powershell.
I am trying to get a list of TCP or UDP ports that the machine is listening on to avoid having to create some program to parse netstat output.