Splatting and Formatting Operator Work Elsewhere Splatting and Formatting Operator Work Elsewhere powershell powershell

Splatting and Formatting Operator Work Elsewhere


Think I'm getting closer, as far as the error goes. As I mentioned earlier, the -Identity parameter requires DistinguishedName property and I was giving it the SamAccountName property.

Below, is the code I changed. I no longer see the error, so that's good.

# Move user to the correct OU.            $LoginNameDN = (Get-ADUser -Identity $LoginName).DistinguishedName            $MoveADObjectParams = @{                Identity = "$LoginNameDN"                TargetPath = 'OU={0},OU=Students,OU={1},OU=accounts,DC=academic,DC=exeter,DC=k12,DC=pa,DC=us' -f @(                    $User.'Grad Year',                    $SchoolCodes[$User.School].Name)            } # End MoveADObjectParams            Move-ADObject @MoveADObjectParams -Verbose -ErrorAction Stop        }