相关疑难解决方法(0)

如何在PowerShell中创建自定义类型以供我的脚本使用?

我希望能够在我的一些PowerShell脚本中定义和使用自定义类型.例如,让我假装我需要一个具有以下结构的对象:

Contact
{
    string First
    string Last
    string Phone
}
Run Code Online (Sandbox Code Playgroud)

我将如何创建它,以便我可以在以下功能中使用它:

function PrintContact
{
    param( [Contact]$contact )
    "Customer Name is " + $contact.First + " " + $contact.Last
    "Customer Phone is " + $contact.Phone 
}
Run Code Online (Sandbox Code Playgroud)

这样的事情是可能的,甚至在PowerShell中推荐?

powershell scripting

75
推荐指数
5
解决办法
7万
查看次数

我们可以在PowerShell脚本中实现.NET接口吗?

假设我们在用C#编写的.NET类库中定义了一些接口.有没有办法在PowerShell脚本中实现这些接口?

称之为业务需求.作为供应商,我们提供一些由客户实施的接口来使用我们的产品.我们的一位客户希望通过PowerShell脚本执行此操作.

.net c# powershell powershell-3.0

9
推荐指数
2
解决办法
5161
查看次数

标签 统计

powershell ×2

.net ×1

c# ×1

powershell-3.0 ×1

scripting ×1