PS H:\> H:\FindDuplIDs.ps1 Get-ADObject : One or more properties are invalid. Parameter name: msRTCSIP-Primar yUserAddress At H:\FindDuplIDs. ps1:11 char:12 + $Objects = Get-ADObject -LDAPFilter $Filter -Properties $Prop + ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~ + CategoryInfo : InvalidArgument : (:) [Get-ADObject], ArgumentExcepti on + FullyQualifiedE rrorId : One or more properties are invalid. Parameter name: msRTCSIP-Primar yUserAddress,Mi crosoft.ActiveD irectory.Manage ment.Commands.G etADObject Any Idea on the cause of that error when running the script? And how I can mitigate it? This script is exactly what I need but I can't get it to run.
I think I have it figured out. # Retrieve all objects where any of the attributes are assigned values. $Prop = @("userPrincipalName","mail"," proxyAddresses" ) $Filter = "(|(userPrincip alName=*)(mail= *)(proxyAddress es=*))" $Objects = Get-ADObject -LDAPFilter "$Filter" -Properties $Prop I removed the unknown parameter from linds 9 and 10 and it seems to run fine now
At C:\Batchfiles\Find-DuplID.ps1: 24 char:33 + $PrimAddr = $Object.msRTCSI P-PrimaryUserAd dress + ~~~~~~~~~~~~~~~ ~~~~ Unexpected token '-PrimaryUserAd dress' in expression or statement. + CategoryInfo : ParserError: (:) [], ParseException + FullyQualifiedE rrorId : UnexpectedToken I see the attribute in AD using dsa.msc, but script doesn't like it. Do I need to add in a module? Thanks, Kurt
Sorry, my test lab does not have that attribute, so I missed this issue. The msRTCSIP-PrimaryUserAddress attribute is one of the few with an lDAPDisplayName that includes the dash character. PowerShell interprets the string following the dash as a parameter, which makes no sense (since there is no leading space). The fix is to quote the attribute name in the statement that raises the error. I will revise the code shortly.