Most samples start off by doing a m365 status check to see if they are still logged in to their Microsoft 365 environment. Which looks something like this.
$m365Status = m365 status
if ($m365Status -eq "Logged out") {
m365 login
}
The if condition here will always be false because we aren't converting the output of m365 status to an object.

This isn't a new issue because it also occured within the repo script samples and was recently fixed aswell. pnp/script-samples#298
The way we can resolve this, is by updating the status command to output as text. Like the following:
$m365Status = m365 status -o text
if ($m365Status -eq "Logged out") {
m365 login
}
I would suggest we apply this to the following script samples:
- analyze-users-haveibeenpwnd
- delete-m365-groups-and-sharepoint-sites
- replace-membership-of-selected-groups
- replace-owner-with-a-different-one
- flow-runs-day-summary
- add-multiple-tasks
- add-multiple-lists-in-multiple-sites
- copy-files-to-another-library
- list-all-checked-out-files (all 3 samples)
- list-all-files-specific-name
- list-all-list-folders-itemcount
- list-large-files-within-a-site
- list-site-collection-lists
- list-site-collection-owners
- list-site-externalusers
- replace-site-collection-admin
- setup-example-site
- upload-local-files-and-folder
- add-bulk-users-teams
- create-team-and-add-members-and-owners
- export-all-channels-teams
- install-personal-app
- list-all-tabs-teams
- list-all-teammembers-teams
- list-teams-owners-and-members
- remove-personal-app
- share-socialchampions
Most samples start off by doing a m365 status check to see if they are still logged in to their Microsoft 365 environment. Which looks something like this.
The if condition here will always be false because we aren't converting the output of m365 status to an object.
This isn't a new issue because it also occured within the repo
script samplesand was recently fixed aswell. pnp/script-samples#298The way we can resolve this, is by updating the status command to output as text. Like the following:
I would suggest we apply this to the following script samples: