SharePoint / SharePoint/sp-dev-docs

Connect-SPOService: Object reference not set to an instance of an object.

Open
#9,434 109 comments 30 reactions 1 assignee View on GitHub

@Ashlesha-MSFT is already working on this.

Since Apr 21, 2026.

area:sharepoint-embedded Needs: Author Feedback type:bug-confirmed
Dominant language
PowerShell
Stars
1.4k
Forks
1.1k
Avg merge
4d 12h
Merged PRs (30d)
12

Description

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

other (enter in the "Additional environment details" area below)

Developer environment

macOS

What browser(s) / client(s) have you tested
  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)
Additional environment details

PowerShell module Microsoft.Online.SharePoint.PowerShell v16.0.24322.12000

Describe the bug / error

I'm currently trying to get started with Sharepoint Embedded (https://learn.microsoft.com/en-us/sharepoint/dev/embedded/mslearn/m02-03-hol). To be able to follow this guide, I joined the Microsoft developer program (https://developer.microsoft.com/en-us/microsoft-365/dev-program) and tried to connect to the environment created by the assistant there.

I could find the there described option to enable Sharepoint Embedded, but when I tried to create the container type, I should run the command Connect-SPOService which errored by giving me an error message I could not find out what to do next:

Connect-SPOService: Object reference not set to an instance of an object.

As of what I've found online, there seems to be some error in the script provided by this package. I'd love to be able to have a look at the code which you run here, but this doesn't seem to be open source ...

Steps to reproduce
  1. Install-Module -Name Microsoft.Online.SharePoint.PowerShell
  2. Import-Module "Microsoft.Online.SharePoint.PowerShell"
  3. Connect-SPOService -Url "https://******-admin.sharepoint.com"
Expected behavior

Based on the documentation, I should be prompted for my credentials, but I wasn't. I tried to add some parameters, as described in the documentation of the script (https://learn.microsoft.com/en-us/powershell/module/sharepoint-online/connect-sposervice?view=sharepoint-ps). Adding the parameter -credential, as shown in the first example, I was first prompted for my password, but the application then stopped with the same error, after I entered the password.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.