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

前端 未结 4 1873
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 06:46

    First, make sure the assembly is loaded using

    [System.Reflection.Assembly]::LoadFrom("C:\path-to\my\assembly.dll")
    

    Next, use the fully qualified class name

    $MyCompObj = New-Object My.Assembly.MyComputer
    

提交回复
热议问题