I’m trying to do a compare-object on two variables and not getting the results I expect.
I have this:
PS E:\> $Base = $xml.SelectNodes("//Field[@name='visibleFields']/*/Item/@id")
PS E:\> $base
#text
-----
FREDabc
FREDdef
FREDghi
PS E:\> new-variable FREDabc
PS E:\> $Ref = gv FRED*
PS E:\> $Ref
Name Value
---- -----
FREDabc
PS E:\> compare-object $Base $Ref
InputObject SideIndicator
----------- -------------
System.Management.Automation.PSVariable =>
{id, id, id, id...} <=
{Name, Expression} <=
PS E:\> $Base | gm
TypeName: System.Xml.XmlAttribute
Name MemberType Definition
---- ---------- ----------
ToString CodeMethod static string XmlNode(psobject instance)
AppendChild Method System.Xml.XmlNode AppendChild(System.Xml.XmlNode newChild)
Clone Method System.Xml.XmlNode Clone()
CloneNode Method System.Xml.XmlNode CloneNode(bool deep)
CreateNavigator Method System.Xml.XPath.XPathNavigator CreateNavigator()
Equals Method bool Equals(System.Object obj)
GetEnumerator Method System.Collections.IEnumerator GetEnumerator()
GetHashCode Method int GetHashCode()
GetNamespaceOfPrefix Method string GetNamespaceOfPrefix(string prefix)
GetPrefixOfNamespace Method string GetPrefixOfNamespace(string namespaceURI)
GetType Method type GetType()
InsertAfter Method System.Xml.XmlNode InsertAfter(System.Xml.XmlNode newChild, System.Xml.Xm...
InsertBefore Method System.Xml.XmlNode InsertBefore(System.Xml.XmlNode newChild, System.Xml.X...
Normalize Method System.Void Normalize()
PrependChild Method System.Xml.XmlNode PrependChild(System.Xml.XmlNode newChild)
RemoveAll Method System.Void RemoveAll()
RemoveChild Method System.Xml.XmlNode RemoveChild(System.Xml.XmlNode oldChild)
ReplaceChild Method System.Xml.XmlNode ReplaceChild(System.Xml.XmlNode newChild, System.Xml.X...
SelectNodes Method System.Xml.XmlNodeList SelectNodes(string xpath), System.Xml.XmlNodeList ...
SelectSingleNode Method System.Xml.XmlNode SelectSingleNode(string xpath), System.Xml.XmlNode Sel...
Supports Method bool Supports(string feature, string version)
WriteContentTo Method System.Void WriteContentTo(System.Xml.XmlWriter w)
WriteTo Method System.Void WriteTo(System.Xml.XmlWriter w)
Item ParameterizedProperty System.Xml.XmlElement Item(string name) {get;}, System.Xml.XmlElement Ite...
#text Property System.String #text {get;set;}
PS E:\> $Ref | gm
TypeName: System.Management.Automation.PSVariable
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
IsValidValue Method bool IsValidValue(System.Object value)
ToString Method string ToString()
Attributes Property System.Collections.ObjectModel.Collection`1[[System.Attribute, mscorlib, Version=2.0.0.0, Cu...
Description Property System.String Description {get;set;}
Module Property System.Management.Automation.PSModuleInfo Module {get;}
ModuleName Property System.String ModuleName {get;}
Name Property System.String Name {get;}
Options Property System.Management.Automation.ScopedItemOptions Options {get;set;}
Value Property System.Object Value {get;set;}
Visibility Property System.Management.Automation.SessionStateEntryVisibility Visibility {get;set;}
PS E:\> compare-object $Base $Ref -property name
name SideIndicator
---- -------------
FREDabc =>
<=
PS E:\> compare-object $Base $Ref -property #text
Compare-Object : Missing an argument for parameter 'Property'. Specify a parameter of type 'System.Object[]' and try ag
ain.
At line:1 char:52
+ compare-object $VisibleFields $Operations -property <<<< #text
+ CategoryInfo : InvalidArgument: (:) [Compare-Object], ParameterBindingException
+ FullyQualifiedErrorId : MissingArgument,Microsoft.PowerShell.Commands.CompareObjectCommand
PS E:\>
How would I compare the Name property in $Base to the #Text property in $Ref?
Thanks