How to use New-Object of a class present in a C# DLL using PowerShell

前端 未结 4 1872
Happy的楠姐
Happy的楠姐 2021-02-19 06:32

I have a class in C# say for example

public class MyComputer : PSObject
{
    public string UserName
    {
        get { return userName; }
        set { userN         


        
4条回答
  •  半阙折子戏
    2021-02-19 07:13

    Is the MyComputer class in a namespace? If so, you probably need to use the namespace-qualifed name of the class in the New-Object command.

    Also, PowerShell does not like the public names DeviceName and deviceName which differ only in case. You probably meant to declare deviceName private. (But why not use auto-properties?)

    Finally, stej is correct. There is no need to derive the MyComputer class from PSObject.

提交回复
热议问题