How to expose functionality to PowerShell from within your application

前端 未结 3 1123
野的像风
野的像风 2021-02-09 14:58

I was listening to the podcast about PowerShell 2.0 that Scott Hanselman did. In that episode, they talked about the possibilities to extend your application to expose functiona

3条回答
  •  [愿得一人]
    2021-02-09 15:47

    There are a couple of levels of PowerShell support, and not many people explain this well.

    1. .NET classes. Yes, anything with a .NET API can be accessed by PowerShell without you doing anything extra! But, you don't get quite all of the extra PowerShell features. The least amount of work.
    2. A PowerShell module with cmdlets, scripts, and/or functions. This will require writing some PowerShell specific code to wrap around your existing API. If you go this route, you should sit down and learn the best practices for PowerShell design and think out your PowerShell support. This is more work required to do it right.
    3. PowerShell providers. Providers are a special case, not everything should have a provider. You need to really consider whether your information really makes sense in a file system view.

    This doesn't apply to your question, but I'll add it for completeness.

    1. Hosted PowerShell. You can host PowerShell code in your app, or access PowerShell functionality from your app. This makes sense in some situations, but is also a specialized case of PowerShell support.

提交回复
热议问题