`[psobject]` vs `[object]`?

I’m writing a function where the parameter can be a number of types and then taking action based on what type gets passed. Which is a better practice: using System.Object or System.Management.Automation.PSObject? If I define this in the parameter block, will it typecast whatever is passed to a psobject? e.g.:

[Parameter(Position = 0, Mandatory, ValueFromPipeline)] [ValidateScript({$PSItem -is [string] -or $PSItem -is [int]})] [System.Object] $Item 

Also kind of a side-note: what gives with pscustomobject and psobject? I notice when getting the members of pscustomobject, it displays the typename as psobject. Meanwhile, pscustomobject is definitely a type in the SDK, but without a public constructor?

submitted by /u/TheIncorrigible1
[link] [comments]

Leave a Reply