Share via

Getting error while creating a office 365 user and assigning office 365 group to them by running following powershell cmdlets

Anonymous
2018-08-16T09:39:55+00:00

CMDlets:

New-MsolUser -DisplayName 'Vivek Jain' -UserPrincipalName ******@XXX.onmicrosoft.com -UsageLocation IN

Set-MsolUserLicense -UserPrincipalName ******@XXX.onmicrosoft.com -AddLicenses XXX:ENTERPRISEPACK

Add-UnifiedGroupLinks –Identity ******@XXX.onmicrosoft.com –LinkType Members –Links ******@XXX.onmicrosoft.com

If i run all cmdlets in single run then it produces error:

Couldn't find object "*****@XXX.onmicrosoft.com". Please make sure that it was spelled correctly or specify a different object.*

+ CategoryInfo          : NotSpecified: (*****@XXX.onmicrosoft.com:UnifiedGroupIdParameter) [Add-UnifiedGroupLinks], ADNoSuchObjectException*

+ FullyQualifiedErrorId : [Server=BMXPR01MB1000,RequestId=41af16db-ec3d-4824-97a7-2bea7d2ad832,TimeStamp=16-08-2018 09:23:36] [FailureCategory=Cmdlet-ADNoSuchObjectException] 1

CDFE0F2,Microsoft.Exchange.Management.RecipientTasks.AddUnifiedGroupLinks

+ PSComputerName        : outlook.office365.com

some timeas error is:

WARNING:  Unable to add members Vivek Jain to group object.

We failed to update the group mailbox. Please try again later.

+ CategoryInfo          : NotSpecified: (:) [Add-UnifiedGroupLinks], AADException

+ FullyQualifiedErrorId : [Server=BMXPR01MB1000,RequestId=7f7ad989-d182-4532-b058-2fcc32d87bfc,TimeStamp=16-08-2018 09:01:46] [FailureCategory=Cmdlet-AADException] 8E755CFF,Mic

rosoft.Exchange.Management.RecipientTasks.AddUnifiedGroupLinks

+ PSComputerName        : outlook.office365.com

If i run each cmdlets in some duration then it works fine.

i.e. Run below cmdletsNew-MsolUser -DisplayName 'Vivek Jain' -UserPrincipalName ******@XXX.onmicrosoft.com -UsageLocation IN

Set-MsolUserLicense -UserPrincipalName ******@XXX.onmicrosoft.com -AddLicenses XXX:ENTERPRISEPACK

take few minutes break then run below cmdlets

Add-UnifiedGroupLinks –Identity ******@XXX.onmicrosoft.com –LinkType Members –Links ******@XXX.onmicrosoft.com

I want to run all cmdlets in single run. Please help me.

Microsoft 365 and Office | Install, redeem, activate | For home | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

6 answers

Sort by: Most helpful
  1. Anonymous
    2018-08-16T11:40:06+00:00

    Unfortunately account creation and license assignment take time. Maybe it is less than 5 minutes, problem is that the time it takes varies.

    I myself use these scripts as well (automated during the night).

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2018-08-16T11:33:28+00:00

    Hi MerlijnDonk,

    Are you talking about 300 seconds???

    My platform doesn't allow this much delay between commands. If i do like as you suggested then my whole operations get failed.

    Do we have any other approach (Instead of waiting | sleep) to resolve this issue.

    Thanks for replying.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2018-08-16T10:13:42+00:00

    I think you need at least 300 between each command

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2018-08-16T10:09:07+00:00

    Hi MerlijnDonk,

    I already tried Start-Sleep with 20 seconds limit. That is also not working.

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2018-08-16T09:54:06+00:00

    Hi,

    I am an Independent Advisor here to help you. I'm sorry to hear that you're having difficulties.

    You could add a pause:

    Start-Sleep 5
    5 seconds

    Please let me know I'm happy to try to solve your problem.

    Was this answer helpful?

    0 comments No comments