Can I access My Custom.NET Class from PowerShell?

I have a few questions and doubts regarding PowerShell and .NET classes.

I am trying to write a class 'foo' that will call the Rest web service and perform some tasks. If I bred a class in the GAC, can I call it from PowerShell?

+6
source share
2 answers

Try:

ADD-TYPE -AssemblyName myassemblyname 

or

 [System.Reflection.Assembly]::LoadWithPartialName("myassemblyname") 

to access the method / properties of your assembly you can do this:

 [myassemblyname]::mymethod() [myassemblyname]::myproperty 
+11
source

You can load the assembly using the Add-Type cmdlet or using the System.Reflection.Assembly class, and then you can use the New-Object to create objects from your assembly classes.

+3
source

Source: https://habr.com/ru/post/908042/


All Articles