I have a class in C# say for example
public class MyComputer : PSObject
{
public string UserName
{
get { return userName; }
set { userN
You don't need to have PSObject
as base. Simply declare class without base.
Add-Type -typedef @"
public class MyComputer
{
public string UserName
{
get { return _userName; }
set { _userName = value; }
}
string _userName;
public string DeviceName
{
get { return _deviceName; }
set { _deviceName = value; }
}
string _deviceName;
}
"@
New-Object MyComputer | fl *
Later when you will work with the object, PowerShell will automatically wrap it into PsObject
instance.
[3]: $a = New-Object MyComputer
[4]: $a -is [psobject]
True