Connect-PNPOnline returns connection in Dev, but an Array in Prod. (Begging for help) #4844
-
Issue:
Environment infoOperating environment
Get-Module Output Tenant Info
Troubleshooting Attempts
Theories
Cry for helpAppreciate you reading this far. At this point I'm taking shots in the dark and will take any ideas/help I can get. I'm including the verbose error messages below for reference. Error Output:Get-PnPTeamsTeam Output: Nightly Build (Prod)
Get-PnPTeamsTeam Output: Stable Build (Prod)
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Solution:OK, after 12-ish hours I found the compound problem that caused this. I'm recounting in detail for anyone else facing similar issues. In short, dumb script monkey + a corrupt/weird M365Team. Problem 1: The "Connect-PNPOnline returns array for prod only"I built a wrapper around Connect-PNPOnline so I could switch between my dev/staging/prod environments. I used that wrapper to also give a warning if you were connecting to PNP in a production environment. Because of powershell function behavior, that wrapper was creating an inadvertent additional return value, thus automatically changing the function return variable into an Array. I was looking in the wrong place because I thought I was experiencing this bug or something similar. The Lesson of the day: Don't assume that 'return' in powershell overrides what happens above Problem 2: Get-PNPTeamsTeam parsing error.After a lot of digging, I discovered this parsing error was happening when PNP hit a particular team. That team had a '/' in its name. I changed the team name, but that didn't seem to have an effect (maybe I just didn't wait long enough). In the end, the team wasn't that important, so I backed up its data and deleted the team. After that, In the end, I assumed two things were related that weren't and it sent me right down the rabbit hole. I need a drink. Happy coding everyone! |
Beta Was this translation helpful? Give feedback.
Solution:
OK, after 12-ish hours I found the compound problem that caused this. I'm recounting in detail for anyone else facing similar issues. In short, dumb script monkey + a corrupt/weird M365Team.
Problem 1: The "Connect-PNPOnline returns array for prod only"
I built a wrapper around Connect-PNPOnline so I could switch between my dev/staging/prod environments. I used that wrapper to also give a warning if you were connecting to PNP in a production environment. Because of powershell function behavior, that wrapper was creating an inadvertent additional return value, thus automatically changing the function return variable into an Array. I was looking in the wrong place because I though…