Accessing .NET components from Powershell

后端 未结 3 1685
情深已故
情深已故 2020-12-09 18:51

I want to use Powershell to write some utilities, leveraging our own .NET components to handle the actual work. This is in place of writing a small console app to tie the c

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 19:06

    If you want to load an assembly into your PowerShell session, you can use reflection and load the assembly.

    [void][System.Reflection.Assembly]::LoadFrom(PathToYourAssembly)
    

    After you load your assembly, you can call static methods and create new instances of a class.

    A good tutorial can be found here.

    Both books mentioned by EBGreen are excellent. The PowerShell Cookbook is very task oriented and PowerShell in Action is a great description of the language, its focus and useability. PowerShell in Action is one of my favorite books. :)

提交回复
热议问题