web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Adding deployment admins via powershell error

(0) ShareShare
ReportReport
Posted on by 1,747

I'm trying to automate a process to be able to add and remove users as deployment administrators on an automated basis based on a group that is setup within Active Directory. I've got most of it completed however I've run into a CRM specific issue with the users. There are some users who have the same user account name in multiple domains within the same overall forest. The company I work for is currently merging many of these down and for newer users that have only ever been a member of one domain the new-CrmDeploymentAdministrator or remove-CrmDeploymentAdministrator work correctly. However, if the user has been a member of multiple domains within the forest the PowerShell can't find the correct user to associate.

If I run the command against their user explicitly, the command completes without issue, it is only when part of a larger foreach loop where I run into an error message that says: Invalid user name. failed to validate username for given domain. Only existing domain usernames and email addresses are allowed.

The foreach loop looks like this: foreach ($newadmins in $newadmin) { [string] $newadmins = $newadmins New-CrmDeploymentAdministrator -Name $newadmins Write-Output $newadmins - new }

*This post is locked for comments

I have the same question (0)
  • Kokulan Profile Picture
    18,054 on at
    RE: Adding deployment admins via powershell error

    Thanks for sharing the solution

  • Verified answer
    Jarrod Williams Profile Picture
    1,747 on at
    RE: Adding deployment admins via powershell error

    The solution on this had more to do with the output of the script in the compare than anything else.  When I compared the text output of the script I noticed that there were trailing spaces on some of the names where there wasn't on the ones going through and when I put them into the file manually (without  spaces) it worked fine.  

    Resolution was to use a trimend () on the variable to clip white space off the end and then it added the admins without issue.  

  • Jarrod Williams Profile Picture
    1,747 on at
    RE: Adding deployment admins via powershell error

    Hi Kokulan,

    Yep, for the adds I'm pulling from Get-ADGroupMember and getting the domain and SAM name from that.  

    Also, for the accounts I'm getting errors with, if I just manually enter the name and not use any sort of variable it works fine.  

  • Kokulan Profile Picture
    18,054 on at
    RE: Adding deployment admins via powershell error

    You might have already tried but just wanted to check if you tried including the correct domain for the user using sam account?

    6102.ScreenClip-_5B00_170_5D00_.png

    I remember a while ago, I had to use  domainname.local  for it to recognise the user so not sure if you have already tried that

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans