question

MohammedFKadhim-0969 avatar image
0 Votes"
MohammedFKadhim-0969 asked ·

Creating bulk 365 accounts using powershell is no longer working

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
1.jpg (63.0 KiB)
2.jpg (439.8 KiB)
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,
Based on your description, I suggest you post this issue to Microsoft 365 forum:
https://answers.microsoft.com/en-us/msoffice/forum/msoffice_o365Admin

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

0 Votes 0 ·
AndreasBaumgarten avatar image
1 Vote"
AndreasBaumgarten answered ·

Hi @MohammedFKadhim-0969 ,

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

· 6 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello Andreas,
Thanks for the reply.

I've tried running the same command in PowerShell ISE but it simply close as soon as I enter the command without showing any error. Super Weird.

I never updated PowerShell since when I installed Windows years ago. But I keep my Windows up to date so maybe it updates with Windows ? Not sure.

I've installed the latest version of PowerShell 7.1.2 and I for some reason I cannot run the command Connect-MsolService which I always use to connect to my office account. Looks like this version of PowerShell is not recognizing this command ? Take a look at the screenshot below.

70401-bandicam-2021-02-21-21-30-01-469.png

Kind regards,
Mohammed Kadhim


0 Votes 0 ·
AndreasBaumgarten avatar image AndreasBaumgarten MohammedFKadhim-0969 ·

Did you import the MSOnline module?


Kind regards
Andreas Baumgarten

1 Vote 1 ·
MohammedFKadhim-0969 avatar image MohammedFKadhim-0969 AndreasBaumgarten ·

I didn't at first. Now I did but again it is giving me a different error this time. I feel like I'm running lemon PC :D

70387-bandicam-2021-02-21-23-22-23-502.png

Sorry I don't have any experience in MSOnline other than creating bulk 365 accounts.

Kind regards,
Mohammed Kadhim


0 Votes 0 ·
Show more comments
RichMatheisen-8856 avatar image RichMatheisen-8856 MohammedFKadhim-0969 ·

Unless you a specific need to use PowerShell 7 you shouldn't. There are compatibility issues, especially for modules that were designed to run in PowerShell 5.

In your case I think you'll have to use Import-Module MSOnline -UseWindowsPowerShell to begin. There are probably other issues you'll run into with Azure and mixing modules, along with other differences between the two PowerShell executables.

1 Vote 1 ·
RichMatheisen-8856 avatar image RichMatheisen-8856 MohammedFKadhim-0969 ·

PowerShell ISE is no longer supported; it continues to work (for now) but it will receive no further enhancements or bug fixes. Also, it doesn't work with PowerShell 7 unless you follow instructions you'll find online. Switch from ISE to VS Code or Visual Studio instead.

0 Votes 0 ·
IanXue-MSFT avatar image
1 Vote"
IanXue-MSFT answered ·

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.

· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MohammedFKadhim-0969 avatar image
0 Votes"
MohammedFKadhim-0969 answered ·

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

· 2 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I'm glad your problem is solved. Thank you for your update.
If you have other questions, please feel free to post a new case in our forum.

1 Vote 1 ·

Hi @MohammedFKadhim-0969 ,

thanks for your update! And great it's working again.

It never occurred to me to restart the computer to get it working. I learned something new from that, which is great. :-)


Kind regards
Andreas Baumgarten

1 Vote 1 ·