Hello,
Is it possible to successfully run a Get-ADUser cmdlet over port 636? Or do I need to useNew-Object System.DirectoryServices.DirectoryEntry then New-Object System.DirectoryServices.DirectorySearcher instead?
My code below worked fine until I changed the 2nd line from $domain ="fabrikam.com" to$domain ="fabrikam.com:636"
$Today = (Get-Date) $domain ="fabrikam.com:636" $data += Get-ADUser -Server $domain -Filter {(Memberof -eq "CN=Software_AccessGroup,OU=UserAccounts,DC=FABRIKAM,DC=COM") -and (Enabled -eq $true) -and (-Not (AccountExpirationDate -lt $Today)) -and (sAMAccountName -notlike "*_*") -and (mail -like "*") -and (mail -notlike "* *") -and (sn -like "*") -and (givenName -like "*") -and (sAMAccountName -notlike "*0*") -and (sAMAccountName -notlike "*1*") -and (sAMAccountName -notlike "*2*")} -Properties objectGUID, mail, givenName, sn, manager1, sAMAccountName, department, physicalDeliveryOfficeName, friendlyNames | select objectGUID, mail, givenName, sn, manager1, sAMAccountName, department, physicalDeliveryOfficeName, @{L="friendlyNames";E={$_.friendlyNames[0]}} $data | Export-Csv "C:\Temp\Users.csv" -NoTypeInformation
Now I get this error:
Get-ADUser : Server instance not found on the given port.
636 is available on this domain controller, can anyone advise?
Thanks
Stuart