I wanted to separate the creation of a System.Object but can't work with it properly.
- Code: Select all
function Get-NSObject([string]$name, [string]$ip)
$NSObject = New-Object System.Object |
Add-Member NoteProperty Name '' -PassThru |
Add-Member NoteProperty IP'' -PassThru
$NSObject = Get-NSObject("Test", "127.0.0.1")
# I can output it, no problem
write-host ($NSObject | out-string)
# However, I can't get the Properties:
So, how do I get Powershell to return the full System.Object instead of something I can't work with.
I already tried: return [System.Object]$NSObject # but that didn't solve my problem.