Powershell: How to create custom object and pass it to function in powershell?

后端 未结 2 1102
遥遥无期
遥遥无期 2021-01-06 21:24

I want to create a custom object with properties in PowerShell and then pass that object to a function. I found the online example to create custom object, but its using Has

2条回答
  •  情书的邮戳
    2021-01-06 22:10

    You are creating an object. The hash table is just placeholder used to define all properties before turning them into an object.

    Remove the three lines starting with write-output and you should be good. They are unnecessary and makes your function return an array and not just the object like you wanted. Use write-host if you only want to display the values to the screen while testing.

提交回复
热议问题