All posts in Powershell

A bit late on the blog post compared to the other MVPs, but I am honored, humbled and excited to announce I have been renewed as an Office Apps and Services (previously known as Office Servers and Services) MVP for a fifth year in a row! This year is even a bit more special as I have also been awarded the Cloud and Datacenter Management MVP for the first time, for my contributions in the PowerShell community!

Thanks to Microsoft community for giving me the opportunity to share my knowledge, I will continue to share my passion for Office 365, SharePoint, Flow and of course PowerShell! Special mention to the whole team at Valo Intranet who keeps encouraging me to do more and enables me to give back to community as much as I do! All of the five MVPs on the team got renewed and I am looking forward to creating awesome content with all of them this upcoming year!

5/5 (4)

Please rate this

If you’ve followed this blog for a while, you know that I am a huge fan of Pluralsight for their content, and that I also create courses with them! One of the amazing things that Pluralsight created in the last year is learning paths, here is how they define a learning path:

It can be tough to know where to start learning. Paths combine specific courses and tools into one experience to teach you any given skill from start to finish. Paths are aligned to an individual’s knowledge level, to help you and your team develop the right skills in the right order.

Basically, it’s hand-picked courses on a certain topic, that will allow you to master a skill! Not only that, but they also have the Skill IQ, which is a quick test that will evaluate you on the subjects covered in that path, and tell you exactly what your strong points, and weak points are! It’s really a new learning experience that I love!

Back to PowerShell! In the past month, Pluralsight has released two new learning paths for PowerShell! The first one is called Windows PowerShell: Essentials and as the name says, after you finish this path, you should have the knowledge to create basic PowerShell scripts, handle errors, and automating processes! The path is made up of 6 courses, for a total of 16 hours of content! I have listened to most of the courses, and believe me, even as someone who does PowerShell almost daily, you will learn something! You can find the path over here: https://spvlad.com/PSEssentials

Master PowerShell

The next path is a more advanced one and it’s called Windows PowerShell: Scripting and Toolmaking . This path is longer, with 30 hours of content split up in 13 courses, this path covers some advanced topics, but knowing them will really take your scripts, and productivity to the next level! Here are some of the topics covered:

  • Toolmaking fundamentals
  • Building advanced PowerShell functions and modules -Best practices for PowerShell usage
  • Reporting with PowerShell HTML
  • Debugging PowerShell in VS Code
  • Getting a grasp of PowerShell remoting fundamentals
  • Accessing SQL Server databases with PowerShell
  • Building PowerShell GUIs in WPF
  • Testing PowerShell with Pester
  • Utilizing Windows Workflows with PowerShell

Master PowerShell

As always, Pluralsight content is created by the best in the industry, and the list of Authors below should speak for itself!

Master PowerShell

Check out the paths at the following links, and make sure you share your experience in the comments!

 

Leave a comment and don’t forget to like the Absolute SharePoint Blog Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.
5/5 (1)

Please rate this

While doing a workshop about PowerShell for Office 365 recently, and working with the Exchange Online PowerShell Module, which is needed to authenticate to Exchange Online with MFA , a lot of my students have hit the following error: Application cannot be started. Contact the application vendor.

Exchange Online PowerShell Module Error: Application Cannot be Started

Even if the Details tab don’t say much, this is an easy fix! This is happening only when downloading the Exchange Online PowerShell Module by using Chrome or Firefox, so the fix is simple: Use Internet Explorer to download the Exchange Online PowerShell Module! That’s it!

PS: If you want to know how to connect to all Office 365 using Multi Factor Authentication, check out this blog: Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Leave a comment and don’t forget to like the Absolute SharePoint Blog Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.
5/5 (7)

Please rate this

I’ve been a big fan of PowerShell for Office 365 for a while now, and with new features coming out in Office 365 that are only configurable by PowerShell, it’s more important than ever to be able to at least master the basics, but you absolutely need to know PowerShell for Office 365 in order to have full control of your tenant.

Resources to learn PowerShell for Office 365

Jeffrey Snover, creator of PowerShell and Technical Fellow at Microsoft explains it in a more direct way

When someone answered that their clients do not listen, he was pretty direct with his reply.. you need to learn PowerShell to stay relevant , and even more important to learn it as an Office 365 admin.

So, here are some resources, depending on what type of learner you are!

Books

Books are really ways to learn a topic from start to master, and even if they cost some dollars, they’re always a good investment!

Learn PowerShell for Office 365

Essential PowerShell for Office 365: Managing and Automating Skills for Improved Productivity
Take your Office 365 skills to the next level. Master PowerShell for Office 365 to stay competitive in today’s world of highly sought after cloud management skills. With expert guidance, IT pros will learn how to leverage the muscle of PowerShell to automate many advanced administrative tasks not otherwise accessible in the Office 365 Admin Center. You will discover how to unlock configuration options and automate tasks in order to free up valuable time and resources.

Get it on Amazon at the following links:

Video Training

NOTE: Pluralsight is a paid resource unlike Channel9, Youtube, and Microsoft Virtual Academy which are free. The quality they provide is also superior because of all the quality checks they go through, and the instructors are one of the best in the industry. The Pluralsight courses have a link to where you can get a free trial and decide for yourself if paying a subscription or not is worth it, but the 10 day free trial should allow you to view all those courses for free.

Learn PowerShell for Office 365

PowerShell for Office 365
In this course, you will learn how to use PowerShell to manage Office 365 services. You will learn how to connect and manage users and licensing, SharePoint Online, Exchange Online, Compliance Center and last but not least, Skype for Business Online.

Learn PowerShell for Office 365

PowerShell Playbook for Office 365
A more advanced look at multiple real-life scenarios that span across all Office 365 Services and show you how your PowerShell for Office 365 skills can be applied in your day to day life

PowerShell for common Office 365 Operations
In this 300 level session, you will learn how to automate the management of Office 365 using Windows PowerShell. We will discuss how to connect Windows PowerShell to Office 365, tour the Office 365 cmdlets, and demonstrate how to manage domains, users, and services including Exchange Online, and SharePoint Online.

Support Corner: Using PowerShell to Manage Office 365 Users
Join us in this fast-paced demo to learn how to manage Office 365 users using PowerShell. Experts show you how to create and delete users, update user IDs and passwords, assign licenses and groups, and much more.

Blogs / Links

This a list of blogs, or Microsoft Docs ressources on PowerShell for Office 365! All those are free! This list is currently in construction, and will be better organized in the future!

 

Leave a comment and don’t forget to like the Absolute SharePoint Blog Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.
5/5 (6)

Please rate this

Whether you want to do some reports or debugging, you might need to quickly find out what Office 365 Groups a user is a member or Owner of! You could go in the user’s profile, see all the groups, find out which ones are Security, which ones are Distribution Groups, and which ones are Office 365 Groups. or you could do an easy PowerShell cmdlet!

Find all the Office 365 Groups a user is a Member of with PowerShell

Since we will be playing with Exchange Online, you first need to connect to Exchange!

 

Next up, I will save the E-mail of the person I am looking for in a variable called UserEmail, and use the GetMailbox cmdlet to save the Mailbox object of that user in a variable called Mailbox.

 

After we have this information, we can use the Get-UnifiedGroup PowerShell cmdlet, together with the Get-UnifiedGroupLinks cmdlet to find which groups this user is a member of!

To find all the Office 365 Groups a user is a member of, we would use the following cmdlet:

We then have all those groups stored in a variable, and we can use them as we wish inside PowerShell!

Find all the Office 365 Groups a user is a Member of with PowerShell

To find all the Office 365 Groups a user is an owner of, we would use the following cmdlet:

As you see, the only thing that changed is the -LinkType parameter from Members to Owners! We now also have all those groups stored in a variable to use as we wish in PowerShell!

Find all the Office 365 Groups a user is a Member of with PowerShell

 

Follow me on Social Media and Share this article with your friends!

Leave a comment and don’t forget to like the Absolute SharePoint Blog Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.
5/5 (5)

Please rate this

Whether you want to do some reports or debugging, you might need to quickly find out what Distribution Groups a user is a member of! You could go in the user’s profile, see all of the groups , find out which ones are Security, which ones are Distribution Groups.. or you could do an easy PowerShell cmdlet!

Find all the Distribution Groups a user is a member of with PowerShell

Since we will be playing with Exchange Online, you first need to connect to Exchange!

 

Next up, I will save the Username of the person I am looking for in a variable called Username

And then, I will use this cmdlet which will get all the Distribution Groups in my tenant, and then find the ones where my username is in the members! (This assumes your e-mail address is the same as the username! If that’s not the case, you can simply put the e-mail in the UserName variable and it will work!)

You can now either Display it , or do another action such as removing the user from all of them!

Find all the Distribution Groups a user is a member of with PowerShell in Office 365

That’s it! As you see this is really an quick and easy PowerShell snippet!

 

Leave a comment and don’t forget to like the Absolute SharePoint Blog Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.
4.57/5 (7)

Please rate this

You cannot have full control of your Office 365 tenant, if you do not know how to use PowerShell for Office 365, since there are a ton of configurations, and settings that are only configurable via PowerShell, and not via the Office 365 Admin Center! Not to mention, all the automation capabilities that PowerShell allows you to script, so you save time and money. Since most accounts admin accounts are (or should be) configured with Multi Factor Authentication, here is a small guide on how to connect to all the Office 365 services with PowerShell and Multi Factor Authentication enabled!

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Azure Active Directory

Once you have the Azure Active Directory module installed, connecting with Multi Factor Authentication is done by specifying the AccountId parameter, and not a full credential object as we would do with single factor authentication. This will Open up a window, asking you to enter the password for that account, and then your second authentication method as seen below.

 

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

SharePoint Online

When we connect to SharePoint Online using PowerShell, we use the Connect-SPOService cmdlet as usual as well as the URL parameter, which is the URL of your SharePoint Online Admin Center, and simply skip specifying the -Credentials parameter. This will open a pop-up window asking for our credentials, as well as the second method of Authentication as you can see below!

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Exchange Online

While the previous two were easy, this one is a bit more complicated since we need to download a module, whereas to connect with Single Factor Authentication there is nothing to download! From the Exchange Online Admin Center, go to the Hybrid section, and click on Configure under the Exchange Online PowerShell module.

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

You need to do this with Internet Explorer, or else you will be getting a beautiful “Application Cannot Be Started” error as we talked about in this blog! Exchange Online PowerShell Module Error: Application Cannot be Started – Contact the Application Vendor

Once you have the Exchange Online Module, you need to use the Connect-EXOPSSession PowerShell cmdlet, and specify the user account that you will be connecting with.

 

If you are in Office 365 Germany, you need to provide a few more parameters, as seen in the following example.

 

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Office 365 Security and Compliance Center

To connect to the Office 365 Security and Compliance Center with Multi Factor Authentication, you need the same PowerShell module as Exchange Online, about which we talked earlier, but you will be using the Connect-IPPSSession PowerShell cmdlet as seen in the following example.

If you are part of Office 365 Germany, you will need to provide the additional parameters seen below.

 

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Skype for Business

To connect to Skype for Business Online using Multi Factor Authentication , you need to use the New-CSOnlineSession PowerShell cmdlet

 

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Microsoft Teams

To Connect to Microsoft Teams, you use the Connect-MicrosoftTeams PowerShell cmdlet, and specify the -AccountID parameter. Similar to the other services, you will get a prompt asking you to input your password, and second method of authentication.

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

That is it, we have now looked at how to connect to all Office 365 Services, using PowerShell and Multi Factor Authentication!

Leave a comment and don’t forget to like the Absolute SharePoint Blog Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.
5/5 (4)

Please rate this

While working on some reporting with PowerShell and Office 365, I have discovered something that might be important if you use the Get-SPOExternalUser PowerShell cmdlet to create reports on your SharePoint Online external users.

Get-SPOExternalUser PowerShell

At the end of 2017, Microsoft has released a new , simpler, and nicer way to share SharePoint Online content with your external partners, allowing them to log in with a simple pin / e-mail validation , without them needing to have a Microsoft account anymore. Users loved it, but it seems the PowerShell module hasn’t yet been updated to show those new users yet. Microsoft is already aware of this problem and they have an issue open on the GitHub site for the SharePoint Online PowerShell Module.

This is valid as of the February 2018 version of the SharePoint Online PowerShell Module and I will update this blog with the version when Microsoft fixes it or gives an official workaround . You can also check live updates directly on the issue on GitHub!

The Bug

To show you the bug, I will first invite an external user to a document in a modern SharePoint Online site called Modern Share Test, you can see the screenshot of the invite below.

Get-SPOExternalUser PowerShell

I will then navigate to outlook for this example, accept the invite and then log in to view the document shared with me. As you see in the screenshots below, I am first asked to validate by e-mail, Microsoft Sends me a PIN number, I enter it in the box, and it all works nicely. Off topic, but good job to the Microsoft people who worked on this feature as the end-user experience is amazing.

Get-SPOExternalUser PowerShell

Get-SPOExternalUser PowerShell

Now I will go to PowerShell and run a Get-SPOExternalUser on that Site Collection, and as you see below, it only returns a user, and it’s not the one we just invited!

Get-SPOExternalUser PowerShell

However, if I run an Get-SPOUser cmdlet against the same site, we can see that users added with this modern sharing option have a different login name vs our old external users. The Old naming convention was using #ext# while the new one is urn:spo:guest . In the screenshot below, you can see the accounts in a red box that use modern sharing, and the new naming convention, and the account in the green box that uses the older, Microsoft account method (or Azure B2B).

Get-SPOExternalUser PowerShell

Luckily, even if the Get-SPOExternalUser PowerShell cmdlet is not perfect anymore and only works with accounts that log in with a Microsoft account, we can still create reports using the existing cmdlets.

The Workaround

Here is a small script that I have done that uses the Get-SPOUser cmdlet to return the external users per site collection and exports them to a CSV file at the end and includes the URl so you can also do some nice filtering. There are a ton of ways to do PowerShell, and probably a ton of ways to do this, but here is a way that I have tested, and it works!

 

And here is a screenshot of the CSV, with a Filter on the URL we have talked about before!

Leave a comment and don’t forget to like the Absolute SharePoint Blog Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.

Follow me on Social Media and Share this article with your friends!

5/5 (5)

Please rate this

One of the really cool things that we can do with SharePoint Online is to easily share documents, or sites with external users. The cooler thing even is that now my users can securely share stuff, without having to go through IT, so as an Office 365 Admin, I have a lot more time to be productive, rather then create FBA or AD accounts for my external users as I did On-Premises. However, even if I don’t have to do it myself, I still want to stay informed about what external users have access to what, and who got added to what Site Collection, so I have created a few scripts for it!

My first report is one that I run on a weekly basis, and it’s a easy one: What users have been added to my SharePoint Online environment in the last 7 days? The script is simple, I will use the Get-SPOExternalUser cmdlet to get all of my external users, and I am using the loop that I have blogged about here (Getting More than 50 users with the Get-SPOExternalUser PowerShell cmdlet in SharePoint Online) in order to get more than the limit of 50 per query. I am adding a Where statement, where I specify that I only want users that have the WhenCreated property bigger than Today – 7 days, which means they have been created in the last 7 days! Lastly, I am selecting the properties that I want to show and format the result as a table.

 

Here is what this looks like in action:

Create a report of SharePoint Online External Users with PowerShell

My second report is something that you can either run on a scheduled basis, or only whenever security asks for a more formal report on what is happening in the tenant. What it does is that it will loop trough every Site Collection, and then output every external user that has access to that Site Collection. We will save information about the user in a custom object, as well as the URL of the site they had access to. Lastly, we will export everything to CSV, which as you know allows us to do some nice filtering directly in Excel, or if you want to take it to the next level you can even use it as a data source for a Power BI report let’s say, but we will not get into that topic today. Here is the script:

 

And here is the result in the CSV File opened in Excel! I could use filtering on the URL, or on the User license if I wanted to get more info!

Create a report of SharePoint Online External Users with PowerShell

The last report that I want to show you is a really interesting one that can be really important for your organization: It shows you all the external accounts that have been invited to your tenant using an e-mail address, but they have accepted the invitation and are using a different e-mail address to authenticate to your SharePoint Online. To put it in a more real-life example, let’s say you created a site to work with Contoso, and you invited vlad@contoso.com to your SharePoint Online Site Collection. When receiving the invitation, Vlad has decided to use his personal e-mail address: vlad@hotmail.com to authenticate to your Site Collection. If Vlad decides to leave Contoso, even if his corporate account is disabled, he can still have access to the Site Collection you shared with him since the account that has access is the personal one. If your NDA agreement for example was between Contoso / Your Company and he’s not at Contoso anymore, this can cause you troubles down the road! To get those accounts, you need to use the following parameter, which probably can win an award for one of the longest parameters in PowerShell: ShowOnlyUsersWithAcceptingAccountNotMatchInvitedAccount. Here is the full code:

And here is a screenshot of the result:

Create a report of SharePoint Online External Users with PowerShell

Leave a comment and don’t forget to like the Absolute SharePoint Blog Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.

Follow me on Social Media and Share this article with your friends!

5/5 (5)

Please rate this

One of the reports that a lot of Office 365 admins use, is to see what external users have access to the tenant in SharePoint Online. Luckily, Microsoft offers a PowerShell cmdlet in the SharePoint Online module named Get-SPOExternalUser.

More Than 50 External Users With the Get-SPOExternalUser

While that cmdlet might seem easy and straightforward to use, there is a small catch; it can only return 50 External Users at a time due to a limit on the PageSize Parameter.

More Than 50 External Users With the Get-SPOExternalUser

A lot of scripts that you find on the Internet will give you a command like Get-SPOExternalUser -Position 0 -PageSize 50 … and that will work great , if you have less than 50 users in your tenant! However, if you have more than 50, you will need to do something just a little bit more advanced in order to be able to see all of them. What we will do, is that we will use a For Loop wrapped in a try/catch and try to get 50 users at a time, playing with the -Position parameter until the cmdlet stops returning information. You can view the script below:

 

And here a screenshot example where I am checking the number of users returned, and as you can see it’s over 50, so the script worked!

Leave a comment and don’t forget to like the Absolute SharePoint Blog Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.

Follow me on Social Media and Share this article with your friends!

5/5 (3)

Please rate this