#By Alberto Igbinedion
#.SYNOPSIS
#Compare Groups for specified user from two domains AECUK and CDS
#
#.EXAMPLE
#.\CompareuserGroup.ps1 -$users -$CDSGroup - $AECGroup
Function Compare-Groups { 

[CmdletBinding()]
Param(

    
    [Parameter(
              ValueFromPipeline=$True,
              ValueFromPipeLineByPropertyName=$True)] [string[]]$users
               
                <#[ValidateScript({If ($_ -match 'users,user') {$True 
                } Else { Throw "$_ Please Enter Value User or Users!" } } )]
                $ErrorActionPreference = "Continue"#>    
                
                  
       #[Parameter][string[]]$user1,
       #[Parameter][string[]]$user2,
       #[Parameter][string[]]$CDSGroup,
       #[Parameter][string[]]$AECGroup,
       #[Parameter][string[]]$UserGroup1,
       #[Parameter][string[]]$User1Group2,
       #[Parameter][string]$Export
          
)
Import-Module ActiveDirectory
 


#Get Contents of Text File
        $users =  gc "C:\Scripts\input\UserListBatch8.txt" 

Foreach($Item in $users) 


{
#Get Groups return by GC

        Write-host "$Item._Username" -ForegroundColor Green

        $CDSGroup = (Get-ADPrincipalGroupMembership -Identity $Item -server "bhm1dc01.controlsdata.com" ).Samaccountname
        $AECGroup = (Get-ADPrincipalGroupMembership -identity $Item -server "AEC01A-DC03.aecuk.aec.local" ).Samaccountname


#Compare Groups and export result
# <= shows Groups in CDS not in AEC
# => Shows Groups In AEC not In CDS
compare-object -ReferenceObject $CDSGroup -DifferenceObject $AECGroup | where {$_.sideindicator -eq "=>" }


#Export Results 
        #$Export = export-csv c:\scripts\output\Groupdif.csv

}

}