1

I am trying to run the following powershell command through my application using C#

Get-ADUserResultantPasswordPolicy user1

It returns the values for user1 on domain1 which is my current domain.

when I try to read the values for a user2 on domain2:

Get-ADUserResultantPasswordPolicy domain2\user2

its throwing exception

"Cannot find an object with identity:'user2' under:'DC=domain2,DC=com'.

Is there away to point powershell to the other domains and read the data on that domain?

2 Answers 2

1

Use the -partition parameter:

Specifies the distinguished name of an Active Directory partition. The distinguished name must be one of the naming contexts on the current directory server. The cmdlet searches this partition to find the object defined by the Identity parameter. The following two examples show how to specify a value for this parameter.

-Partition "CN=Configuration,DC=EUROPE,DC=TEST,DC=CONTOSO,DC=COM"

-Partition "CN=Schema,CN=Configuration,DC=EUROPE,DC=TEST,DC=CONTOSO,DC=COM"

Read more here: https://technet.microsoft.com/en-us/library/ee617255.aspx?f=255&MSPPError=-2147217396

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Andrey..actually I don't have knowledge on powershell,can you please give some example on how to retrieve details from other domain using powershell script
1

You can use the -Server parameter with the fully qualified domain name of the domain controller on domain you want to access.

Get-ADUserResultantPasswordPolicy -Identity "USER1" -Server "DC1.YourDomain.com"

3 Comments

Hi Richard...your command working only for current domain users, its not switching to other domain and not bringing any user info.
see..my system is domain joined with domain1. now without switching my system to domain2 I want to access domain2 user details, I used your command in the following way: Get-ADUserResultantPasswordPolicy -Identity "user2" -Server "DC2.domain2.com". Its not connecting
@sam Does the user your logged in with have admin access to the other domains Active Directory, are there any trust between the 2 domains? If not you many need to supply some credentials use the -Credential parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.