I don't think you can tack on the interfaces to the psobject you're creating. However, you can create your type in a C# class that implements the appropriate interfaces and overrides the appropriate methods. You can even define this type in a here string and use Add-Type to compile it and load it into PowerShell. Then you just create that type instead of psobject. It should have all the relevant properties you're interested as well as the ability to do comparison/equality.
Per my comment, here is how to do this in your script with minimal headache bewteen executions i.e. you only need to change the typename variable whenever you change the C# code.
$foo = "Foo"
$src = @"
using System;
public class $foo : IComparable {
public string Name {get; set;}
public int Age {get; set;}
public int CompareTo(object obj)
{
$foo other = obj as $foo;
if (other == null)
throw new ArgumentException("arg must be type $foo or not null");
return Age.CompareTo(other.Age);
}
public override bool Equals(object obj)
{
if (obj == null) return false;
if (Object.ReferenceEquals(this, obj)) return true;
$foo other = obj as $foo;
if (other == null)
throw new ArgumentException("arg must be type $foo or not null");
return Age.Equals(other.Age) && Name.Equals(other.Name);
}
public override int GetHashCode()
{
return Age.GetHashCode() ^ Name.GetHashCode();
}
public override string ToString()
{
return String.Format("Name: {0}, age: {1}", Name, Age);
}
}
"@
if (![Type]::GetType($foo))
{
Add-Type -TypeDefinition $src -Language CSharpVersion3
}
$foo1 = New-Object $foo
$foo1.Age = 47
$foo1.Name = 'Keith'
$foo1
$foo2 = New-Object $foo
$foo2.Age = 45
$foo2.Name = 'John'
$foo2
$foo2 -gt $foo1