Skip Ribbon Commands
Skip to main content

Quick Launch

Todd Klindt's home page > Todd Klindt's Office 365 Admin Blog > Posts > How to Get the Microsoft 365 Connected User with PnP PowerShell
October 08
How to Get the Microsoft 365 Connected User with PnP PowerShell

As I’ve alluded to before, I spend a lot of time in PowerShell, and most of it in the loving embrace of the PnP.PowerShell module. From time to time I find myself wanting to include logic in my scripts based on who the script is being run as, who connected to Microsoft 365. The majority of my connections where with the good old username and password combination. When that’s the case, I could use this to find how who I had connected as:

Connect-PnPOnline -Url

It looks like this:


That worked great, right up to the point where I didn’t just log in with username credentials. For instance, the Sympraxis tenant requires MFA so I have to connect with the –Interactive parameter:


Old Faithful let me down. Back to the drawing board. Poking around the Internet I saw some smart folks were using this method:

$ctx = Get-PnPContext
$UPN = $ctx.Web.CurrentUser.Email


I haven’t tried it yet with Certificate authentication, so I’m not sure how it reports that. The good news is that method also works with a username and password login:


I’ve created a Function, Get-TKPnPCurrentUser, to make that short and easy to use.




Essay help online

You have already realized that you cannot escape from essay writing assignments as it holds a significant amount of your GPA. So, contact online essay writers who can help you to top in your class?

Read More:
 on 1/10/2022 12:44 AM


 on 1/11/2022 12:48 AM

essay help

To pick the greatest essay help website, you need to conduct thorough research. The top essay help site may not provide the best essay aid for the work you require. To obtain your money's worth, you must read reviews, check for comments, and conduct extensive research. 
 on 1/12/2022 6:03 AM

Roadrunner email

Oh Wow! Great blog I must say. The thing I like most about your blog is the catchy words that you choose. I am also here to provide information about Roadrunner email problems and settings. If you or your colleague need any help regarding rr email then you may take information from us.

 on 1/13/2022 11:00 PM

Three Types Of Citation Styles You’ll Come Across Often

When writing an academic paper, you’ll notice many students using tools like an hurricane katrina essay often.
 on 1/14/2022 4:06 AM

Nice post

Hi I am running an assignment company who is providing buy coursework service and proofreading service online at cheap cost for more than 10 years.
 on 1/15/2022 2:51 AM


What an amazing post thanks for sharing it with us I also like writing yard because they give

 on 1/18/2022 4:33 AM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.


Body *

Today's date *

Select a date from the calendar.
Please enter today's date so I know you are a real person


Want a message when I reply to your comment? Put your Twitter handle here.