how to get short/netbios name of trusted domain

Solution 1:

You just need to add the -Server argument to your Get-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:

(Get-ADDomain 'dc=mydomain,dc=com' -Server 'dc.mydomain.com').NetBIOSName

You can also combine it with Get-ADDomainController if you don't already know a DC for the target domain.

$dc = (Get-ADDomainController -Discover -DomainName mydomain.com).HostName[0]
(Get-ADDomain 'dc=mydomain,dc=com' -Server $dc).NetBIOSName