@@ -52,7 +52,8 @@ function Copy-ADSIGroupMembership{
5252 param (
5353 [Parameter (Mandatory = $true ,
5454 Position = 0 ,
55- ParameterSetName = " Identity" )]
55+ ParameterSetName = " Identity" ,
56+ ValueFromPipeline = $true )]
5657 [System.string ]$SourceIdentity ,
5758
5859 [Parameter (Mandatory = $true ,
@@ -82,9 +83,16 @@ function Copy-ADSIGroupMembership{
8283 Write-Verbose " [$FunctionName ] Found DomainName Parameter"
8384 $ContextSplatting.DomainName = $DomainName
8485 }
86+ }
87+
88+ process {
8589
8690 # Get SourceIdentity Type
87- $SourceObject = Get-ADSIObject - Identity $SourceIdentity @ContextSplatting
91+ if ($SourceIdentity.GetType ().FullName -eq ' System.String' ){
92+ $SourceObject = Get-ADSIObject - Identity $SourceIdentity @ContextSplatting
93+ } else {
94+ $SourceObject = Get-ADSIObject - Identity $SourceIdentity.DistinguishedName @ContextSplatting
95+ }
8896 $DestinationObject = Get-ADSIObject - Identity $DestinationIdentity @ContextSplatting
8997
9098 switch - Wildcard ($SourceObject.objectclass ){
@@ -98,9 +106,7 @@ function Copy-ADSIGroupMembership{
98106 " *computer" {$DestinationType = " Computer" }
99107 " *user" {$DestinationType = " User" }
100108 }
101- }
102109
103- process {
104110 # GetSourceGroups
105111 If ($SourceType -eq " User" ){
106112 $SourceGroups = (Get-ADSIUser - Identity $SourceIdentity @ContextSplatting ).GetGroups()
0 commit comments