PowerShell Connections to SharePoint with OKTA

%3CLINGO-SUB%20id%3D%22lingo-sub-1765503%22%20slang%3D%22en-US%22%3EPowerShell%20Connections%20to%20SharePoint%20with%20OKTA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1765503%22%20slang%3D%22en-US%22%3E%3CP%3EGreetings%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBackground-%3C%2FP%3E%3CP%3EI%20have%20a%20PS%20script%20that%20provisions%20sites.%20For%20the%20most%20part%2C%20I'm%20using%20PnP%20cmdlets%20and%20everything%20worked%20just%20fine%20until%20OKTA%20was%20enabled.%20Non-MFA%20service%20acco8unts%20are%20not%20an%20option%20right%20now%3B%20different%20topic.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20my%20code%2C%20I%20provision%20a%20new%20site%20then%20go%20into%20a%20loop%20trying%20to%20connect%20to%20the%20new%20site.%20This%20is%20because%20the%20site%20creation%20cmdlet%20returns%20immediately%20and%20the%20site%20takes%20some%20time%20to%20actually%20be%20provisioned.%20The%20problem%20now%20is%2C%20every%20time%20through%20the%20loop%20the%20user%20is%20prompted%20to%20authenticate.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EQuestion-%3C%2FP%3E%3CP%3EHow%20can%20I%20make%20a%20single%20connection%20then%20reuse%20that%20same%20connection%20when%20polling%20for%20the%20site%20to%20have%20been%20created%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Greetings,

 

Background-

I have a PS script that provisions sites. For the most part, I'm using PnP cmdlets and everything worked just fine until OKTA was enabled. Non-MFA service acco8unts are not an option right now; different topic.

 

In my code, I provision a new site then go into a loop trying to connect to the new site. This is because the site creation cmdlet returns immediately and the site takes some time to actually be provisioned. The problem now is, every time through the loop the user is prompted to authenticate.

 

Question-

How can I make a single connection then reuse that same connection when polling for the site to have been created?

 

Thank you!

0 Replies