Cli-microsoft365: Bug report: Sample Script Govern orphand Microsoft Teams misses authentication/login

Created on 7 May 2020  路  3Comments  路  Source: pnp/cli-microsoft365

Description

Tried to run the PowerShell sample "Govern orphaned Microsoft Teams" under https://pnp.github.io/office365-cli/sample-scripts/teams/govern-orphan-teams/

Did a copy and paste approach and the script throws an error. It misses just a minor thing -> authentication. For sure a small and minor thing, but if this script is the first one you are trying to use and you don't have a background in the field, every step helps to make life easier.

Steps to reproduce

Go to https://pnp.github.io/office365-cli/sample-scripts/teams/govern-orphan-teams/
Copy and paste the code to a ps1 file
Execute the script

Expected result

List of orphaned teams

Actual result

Error.

Solution

Adding o365 login -t password -u $(username) -p $(password) from the other teams sample and providing a user and password solves the problem.

Environment

o365 version 2.9.0

question waiting on response

Most helpful comment

Gotcha, and agree with your argument. Was just confused, because the other script had the login thing present, no problem though.

What about a small hello world like chapter in the introduction making the login steps clear? If you agree, I try to create something and let's see if you like it.

But I'm good with closing this one.

All 3 comments

Hey Thomy, thanks for reporting this. We typically don't include the login step in the sample scripts, because if you're already authenticated, it would reset your existing connection. Also, there are different ways to authenticate: interactively by yourself or using credentials, like you mentioned, in a daemon mode. So rather than forcing a particular way of authenticating in a given script, we thought it would make sense to let users choose how they want to authenticate themselves.

I agree, that if you don't use the CLI daily, it might be something that you miss. Given that we would prefer not to dictate how users should authenticate to use the particular script, how could we make it clear that you need to authenticate before you can run the script. Any suggestions?

Gotcha, and agree with your argument. Was just confused, because the other script had the login thing present, no problem though.

What about a small hello world like chapter in the introduction making the login steps clear? If you agree, I try to create something and let's see if you like it.

But I'm good with closing this one.

That would be great! Appreciate your help! 馃憦

Was this page helpful?
0 / 5 - 0 ratings