从Powershell访问.NET组件 [英] Accessing .NET components from Powershell

查看:86
本文介绍了从Powershell访问.NET组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Powershell编写一些实用程序,利用我们自己的.NET组件来处理实际工作。这可以代替编写一个小型控制台应用程序来将呼叫捆绑在一起。我的问题是,在哪里可以找到很好的文档或教程材料来帮助我快速进行跟踪?

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 calls together. My question is where I would find a good source of documentation or tutorial material to help me fast track this?

推荐答案

如果要要将程序集加载到PowerShell会话中,可以使用反射并加载程序集。

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.

EBGreen提到的两本书都很出色。 PowerShell Cookbook非常面向任务,PowerShell in Action是对该语言,其重点和可用性的很好描述。 PowerShell in Action是我最喜欢的书之一。 :)

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. :)

这篇关于从Powershell访问.NET组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆