I have a user object from Active Directory that has properties like distinguished name. I can easily get the domain portion from that, like dc=somedomain,dc=com. If it were the local domain, I could use Powershell: (get-addomain -Identity "dc=mydomain,dc=com").netbiosname to get the short name. But for this external trusted domain, that doesn't work because it just searches within the local domain. Does anyone know of another way to use Powershell to get the short name for the domain of an arbitrary AD user/group?
Powershell – how to get short/netbios name of trusted domain
active-directorypowershell
Related Topic
- Powershell – Scripting help – need to get phone number of AD accounts and then add them to contacts in trusted domain
- Active Directory – How to List All Active Directory Users and Their Group Membership
- Fileserver cannot find any DC’s for trusted domain
- Powershell – How to get UserID of Mail-User via powershell
Best Answer
You just need to add the
-Server
argument to yourGet-ADDomain
call that specifies a DC in that forest. If you were on a non-domain joined machine, you could add-Credential
to explicitly provide credentials as well. But hypothetically, your trust will pass along your current credentials automatically.So the new command would look like this:
You can also combine it with
Get-ADDomainController
if you don't already know a DC for the target domain.