Creating bulk 365 accounts using powershell is no longer working

Mohammed F Kadhim 1 Reputation point
2021-02-21T14:27:03.007+00:00

Hello,
I've been creating 365 accounts in bulk using powershell since more than a year with no problems. However today I no longer able to do that. Basically the powershell windows instantly close after I enter the command.

Below are the steps that I use to create 365 accounts:

  1. After opening powershell with administrator privileges, I enter the following command: Connect-MsolService and then I enter my credentials.
  2. Then I enter the following command: Import-Csv -Path "C:\Users\Alex\Desktop\Sample.csv" | foreach {New-MsolUser -DisplayName $.DisplayName -UserPrincipalName $.UserPrincipalName -Department $.Department -UsageLocation $.UsageLocation -LicenseAssignment $.AccountSkuId -Password $.UserPassword }

The above command simply import a csv file containing all required info. I've been doing that for more than a year. Today as soon as I enter the above command and hit enter, the window show logs and quickly close. I couldn't even read what's in there as the window close pretty quickly. However I managed to record the screen so please take a look at the attached images before and after I enter the above command.70383-1.jpg70327-2.jpg

Kindly note that I'm running Windows 10 Enterprise 20H2

What could possible be wrong?

Kind regards,
Mohammed Kadhim

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,355 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Andreas Baumgarten 95,496 Reputation points MVP
    2021-02-21T14:34:05.653+00:00

    Hi @Mohammed F Kadhim ,

    If you run the same commands in the PowerShell ISE you maybe can read the error message better.

    Did you any updates on PowerShell version or the MSOnline cmdlets?

    Did you check if a newer PowerShell or MSOnline cmdlets version is availabe?

    ----------

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

    Regards
    Andreas Baumgarten

    1 person found this answer helpful.

  2. Ian Xue (Shanghai Wicresoft Co., Ltd.) 29,486 Reputation points Microsoft Vendor
    2021-02-22T10:09:59.807+00:00

    Hi,

    Can you write the error to a file?

    try{ Import-Csv -Path ...}  
    catch{$_.Exception | Select * | out-file C:\temp\error.txt}  
    

    Best Regards,
    Ian Xue

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

    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.

    1 person found this answer helpful.
    0 comments No comments

  3. Mohammed F Kadhim 1 Reputation point
    2021-02-22T11:27:33.193+00:00

    Hello,
    Thanks to all of you.

    The problem is sorted out. And I feel too embarrassed to say how but I'll say what it was anyways.

    Today morning I tried again using the regular PowerShell (v5.1) which wasn't working yesterday. And guess what, it worked. I didn't even do anything to fix it. The newer 7.1 version is installed in different folder.

    I'm the kind of person who use hibernate a lot. The computer didn't restart since a couple of days which probably why PowerShell was buggy. Or at least that's the only explanation I can come up with. So after shutting down my computer and trying again this morning, PowerShell is working again. I feel stupid for not trying to restart my computer before I made this post. But thanks to all of you for your input. I appreciate it.

    Kind regards,
    Mohammed Kadhim