Get-ADComputer from a different domain

by jagan at 2013-04-17 16:03:38

Gurus, I am in Domain A. I want the list of computers from domain B. I looked up online but running out of options.

Please Help! I don’t know what i am doing wrong here.
by DonJ at 2013-04-17 16:08:25
Yeah. Map a drive to the other domain using the ActiveDirectory provider. Then change to that drive when running the command.
by jagan at 2013-04-18 12:04:11
I did exactly what you said. still same issue. please tell me where am I doing wrong?

Import-Module ActiveDirectory
$SearchBase = "CN=ABC,DC=LZREMOTE,DC=com"
cd "Z:“
get-ADComputer -SearchBase $SearchBase -Filter {Name -like ‘LAXDB’} -property * |Sort-Object Name
by DonJ at 2013-04-18 12:11:19
It looks like you’re not connecting to a DC in the domain. Make sure your drive (it doesn’t need to be a single letter, you can name the drive LZREMOTE: if you want) is pointed to that domain, and you may need to specify (a) explicit credentials and (b) a domain controller to connect to when running the command. Make sure the target domain can talk to the AD cmdlets (you need to point to a DC running the Web service).
by jagan at 2013-04-18 12:44:51
Don, thanks for the quick reply! Z drive is mapped as a network drive from LZREMOTE.COM. i connect using a LZREMOTE.COM user account. in MY Serachbase variable, ABC is the domain controller server name. your last part of the comment

"Make sure the target domain can talk to the AD cmdlets (you need to point to a DC running the Web service).” how do i know target domain can talk to AD cmdlets? and yes dc is running the webservice
by DonJ at 2013-04-18 12:50:05
Ah. No, not a network drive. You can actually map a drive, in PowerShell to Active Directory. Run Get-PSProvider (with the AD module loaded) and you’ll see the provider; you’ll notice you have an AD: drive already to your default domain. I think you can run “help ActiveDirectory” for more.