I created a object in Powershell which looks like this:
Class groupObject{
[string] $Name
[string] $Domain
groupObject([string] $inputName, [string] $inputDomain){
$this.Name = $inputName
$this.Domain = $inputDomain
}
setName([string] $inputName){
$this.Name = $inputName
}
setDomain([string] $inputDomain){
$this.Domain = $inputDomain
}
[string] getName(){
return $this.Name
}
[string] getDomain(){
return $this.Domain
}
# Compare two groupObjects.
[boolean] isEqual([groupObject] $ADgroup){
return ($ADgroup.getName() -eq $this.getName() -and $ADgroup.getDomai() -eq $this.getDomain())
}
}
And I've got two ArrayLists containing groupObjects from different sources.
Now I want to compare those two lists and find all groups which are only in one of them. I am trying to use something like this $onlyList2= $List2 | ?{$List1 -notcontains $_}. But I'm not sure how I can do this using my groupObjects. Any suggestions?
Compare-Objectcmdlet?