Powershell script Import-Module activedirectory to another Domain that has Trust Relationship

mark 1 Reputation point
2020-11-17T14:50:30.023+00:00

Hello,

I have a widows server bound to a domain and it runs a script that is basically users new-user but before imports the Module Active Directory. That all works fine

However im being asked to run the same script on another domain, however i have the felling as the existing script is just using Import-Module activedirectory and not specifying a server it will just go to the active directory its bound to and setup the new user account.

Is there anything i could do in the new-user powersehll commend to specify which active directory the new user will be setup on ?

or would i be better off just creating a new script, if i create the new script how would i specify the new domain to setup the new user on?

Thanks

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Andreas Baumgarten 123.4K Reputation points MVP Volunteer Moderator
    2020-11-17T15:01:06.263+00:00

    You can use two parameters off the New-ADuser command:

    -Server -> Specifies the server or ad where the user should be create
    -Credentials -> To provide credentials of a user that is allowed to create the user (if the user running the script is not allowed to create the user in the domain)

    Source: https://learn.microsoft.com/en-us/powershell/module/addsadministration/new-aduser?view=win10-ps

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


  2. Anonymous
    2020-11-18T07:16:34.897+00:00

    Hi,

    You can do that with the cmdlet New-ADUser. Use -Path to specify the OU and -Server to specify the AD DS instance.

    For more details
    https://learn.microsoft.com/en-us/powershell/module/addsadministration/new-aduser?view=win10-ps

    Best Regards,
    Ian

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.