{"id":86153,"date":"2019-07-31T09:00:38","date_gmt":"2019-07-31T17:00:38","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/scripting\/?p=86153"},"modified":"2019-10-29T06:54:00","modified_gmt":"2019-10-29T14:54:00","slug":"reporting-on-microsoft-365-licensing-using-powershell-part-1","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/reporting-on-microsoft-365-licensing-using-powershell-part-1\/","title":{"rendered":"Reporting on Microsoft 365 Licensing using PowerShell \u2013 Part 1"},"content":{"rendered":"<p><strong>Summary<\/strong>: Will Martin discusses how to report on Microsoft 365 licensing in the cloud.<\/p>\n<p>Hello everyone, Doctor Scripto here today to introduce you to a good friend of mine. Will Martin is a PFE in Messaging here at Microsoft and he wanted to share a wonderful solution he found on reporting on Microsoft 365 licensing with PowerShell.<\/p>\n<p>Will my friend, the Blog is now in your most capable hands!<\/p>\n<p>Thanks for the introduction Doctor Scripto!<\/p>\n<p>I came across an interesting problem recently. I was asked by my large Office 365 customer if I could give them a script that would output all their user account licensing data from their Office 365 tenant. I assured them this would be relatively simple, considering I\u2019d done much worse things with PowerShell. But of course, I ran into problems early on. (By the way, I\u2019m not going to tell you how to get into <a href=\"https:\/\/docs.microsoft.com\/en-us\/office365\/enterprise\/powershell\/connect-to-office-365-powershell\">Office 365 PowerShell<\/a>. We\u2019re going to assume you are bright enough to handle that already.)<\/p>\n<p>So, back to the subject at hand: You see, first and foremost, I had to consider that not every user in this customer\u2019s (or most customer\u2019s) Office 365 tenant was going to have the same licensing \u2013 one might have the Enterprise Premium Exchange license and another then Enterprise Pack Exchange license. The data I recovered had to take this into account. So, using a demo tenant (from <a href=\"http:\/\/demos.microsoft.com\">http:\/\/demos.microsoft.com<\/a>), I started figuring out how to pull user licensing information. The obvious command for this appeared to be Get-MsolUser. After creating an unlicensed user account, I ran the command and got the following results:<\/p>\n<p><img decoding=\"async\" width=\"815\" height=\"96\" class=\"wp-image-86154\" src=\"http:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-20.png\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-20.png 815w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-20-300x35.png 300w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-20-768x90.png 768w\" sizes=\"(max-width: 815px) 100vw, 815px\" \/><\/p>\n<p>Note that throughout this document, the commands may be wrapped \u2013 this is due to the size of the PowerShell window \u2013 there are not new-lines within the commands. From our first command, we can obviously see that the user exists and has no license. Now, let\u2019s see what licenses are available in the tenant. For that, we\u2019ll use the Get-MsolAccountSku. Here\u2019s what this command returned:<\/p>\n<p><img decoding=\"async\" width=\"700\" height=\"150\" class=\"wp-image-86155\" src=\"http:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-21.png\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-21.png 700w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-21-300x64.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>As you can see, the enterprise premium SKU has no units available, so we\u2019ll use the Enterprise Pack for licensing our new user. Now let\u2019s get the details of this SKU and see what all it entails. Using this same command, we\u2019ll limit it to the SKU in question with a filter, then see what the ServiceStatus of it is \u2013 or rather what the SKU\u2019s available applications ServiceStatus are. For that, we run the following command:<\/p>\n<p><img decoding=\"async\" width=\"827\" height=\"371\" class=\"wp-image-86156\" src=\"http:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-22.png\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-22.png 827w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-22-300x135.png 300w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-22-768x345.png 768w\" sizes=\"(max-width: 827px) 100vw, 827px\" \/><\/p>\n<p>We can see that SharePoint, Teams, Skype, Exchange and various other Office 365 tools are available in this SKU (those marked as \u201cSuccess\u201d in the above listing). Now, we\u2019ll want to give this user some of these, but not all of them. We\u2019ll grant them licenses in the GUI. (We won\u2019t show that here \u2013 if you need to know how to license a user, you may not want to be reading this just yet.) And once we have it licensed, the Get-MsolUser command shows it as licensed:<\/p>\n<p><img decoding=\"async\" width=\"825\" height=\"106\" class=\"wp-image-86157\" src=\"http:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-23.png\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-23.png 825w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-23-300x39.png 300w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-23-768x99.png 768w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/p>\n<p>Well, that\u2019s certainly useful \u2013 we now know that the user is licensed. But for what? Looks like we\u2019re going to need a bit more information. At this point, we\u2019re going to pop the user info into a variable so we can work with it a bit more readily:<\/p>\n<p><img decoding=\"async\" width=\"829\" height=\"71\" class=\"wp-image-86158\" src=\"http:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-24.png\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-24.png 829w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-24-300x26.png 300w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-24-768x66.png 768w\" sizes=\"(max-width: 829px) 100vw, 829px\" \/><\/p>\n<p>Now we can refer to our user as $DemoUser. What can we see from this user, then? Well, let\u2019s see what anything with \u201clicense\u201d gives us:<\/p>\n<p><img decoding=\"async\" width=\"828\" height=\"167\" class=\"wp-image-86159\" src=\"http:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-25.png\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-25.png 828w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-25-300x61.png 300w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-25-768x155.png 768w\" sizes=\"(max-width: 828px) 100vw, 828px\" \/><\/p>\n<p>Well, that\u2019s certainly better \u2013 and look \u2013 there\u2019s our Enterprise Pack, along with our demo tenant name: {M365x237466:ENTERPRISEPACK}. Note that this is in squiggle braces \u2013 this means it could hold more than one license pack. And indeed, if we add other license packs to this user, we will see them also listed in the same field:<\/p>\n<p><img decoding=\"async\" width=\"825\" height=\"219\" class=\"wp-image-86160\" src=\"http:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-26.png\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-26.png 825w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-26-300x80.png 300w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-26-768x204.png 768w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/p>\n<p>But we don\u2019t want to muddy the waters just yet \u2013 we\u2019ll remove the extra licenses and go back to our $DemoUser variable to see what else we can learn. Let\u2019s look a bit more closely at the Licenses field:<\/p>\n<p><img decoding=\"async\" width=\"786\" height=\"193\" class=\"wp-image-86161\" src=\"http:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-27.png\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-27.png 786w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-27-300x74.png 300w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-27-768x189.png 768w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/p>\n<p>OK, so we\u2019ve got a bit more information here \u2013 we\u2019ve got some \u201cExtensionData\u201d, whatever that might be, an AccountSku and its relevant AccountSkuId (which matches the license field we saw previously), and \u201cServiceStatus\u201d. Let\u2019s see what our account\u2019s ServiceStatus is:<\/p>\n<p><img decoding=\"async\" width=\"614\" height=\"377\" class=\"wp-image-86162\" src=\"http:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-28.png\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-28.png 614w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-28-300x184.png 300w\" sizes=\"(max-width: 614px) 100vw, 614px\" \/><\/p>\n<p>Bingo!! Here we see the service status of each application the user might have been licensed for. Looks like Exchange, SharePoint, Teams, Sway, and a few others show Success, others show some pending statuses (actually, status, but accenting the U, but details \u2026), and the rest showing Disabled. If we look at the licenses we gave the user it shows:<\/p>\n<p><img decoding=\"async\" width=\"521\" height=\"769\" class=\"wp-image-86163\" src=\"http:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-29.png\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-29.png 521w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/07\/word-image-29-203x300.png 203w\" sizes=\"(max-width: 521px) 100vw, 521px\" \/><\/p>\n<p>This makes sense \u2013 several aren\u2019t enabled, others are.<\/p>\n<p>Come back next Wednesday as we continue on with our discussion of Reporting on Microsoft 365 licenses! .<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\">Official Scripting Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p>Your good friend, Doctor Scripto<\/p>\n<p>PowerShell, Doctor Scripto, Will Martin, Microsoft 365, Reporting<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Will Martin discusses how to report on Microsoft 365 licensing in the cloud. Hello everyone, Doctor Scripto here today to introduce you to a good friend of mine. Will Martin is a PFE in Messaging here at Microsoft and he wanted to share a wonderful solution he found on reporting on Microsoft 365 licensing [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1775,1738,685],"tags":[1740,1777,377,1778,1834],"class_list":["post-86153","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-365","category-powershell","category-scripting-techniques","tag-doctor-scripto","tag-microsoft-365","tag-powershell","tag-reporting","tag-will-martin"],"acf":[],"blog_post_summary":"<p>Summary: Will Martin discusses how to report on Microsoft 365 licensing in the cloud. Hello everyone, Doctor Scripto here today to introduce you to a good friend of mine. Will Martin is a PFE in Messaging here at Microsoft and he wanted to share a wonderful solution he found on reporting on Microsoft 365 licensing [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/86153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=86153"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/86153\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=86153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=86153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=86153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}