<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>azure license count Archives - the Sysadmin Channel</title>
	<atom:link href="https://thesysadminchannel.com/tag/azure-license-count/feed/" rel="self" type="application/rss+xml" />
	<link>https://thesysadminchannel.com/tag/azure-license-count/</link>
	<description>Documenting My Life as a System Administrator</description>
	<lastBuildDate>Sat, 11 Nov 2023 02:46:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>
<site xmlns="com-wordpress:feed-additions:1">144174110</site>	<item>
		<title>Get Microsoft 365 License Usage Count Using PowerShell</title>
		<link>https://thesysadminchannel.com/get-microsoft-365-license-usage-count-using-powershell/</link>
					<comments>https://thesysadminchannel.com/get-microsoft-365-license-usage-count-using-powershell/#respond</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Sat, 11 Nov 2023 02:46:27 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[Graph API]]></category>
		<category><![CDATA[Office365]]></category>
		<category><![CDATA[azure license count]]></category>
		<category><![CDATA[check my Office 365 license count]]></category>
		<category><![CDATA[get license count graph api]]></category>
		<category><![CDATA[Get Microsoft 365 License Usage Count Using PowerShell]]></category>
		<category><![CDATA[get-mguserlicensedetail]]></category>
		<category><![CDATA[How do I see all my Office Licenses]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=4920</guid>

					<description><![CDATA[<p>Keeping an eye on the available licenses in your Microsoft tenant is essential to ensuring you and your users have what is needed to keep the business running. Whether you assign licenses directly or you use Group Based Licensing, if&#8230; <a href="https://thesysadminchannel.com/get-microsoft-365-license-usage-count-using-powershell/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/get-microsoft-365-license-usage-count-using-powershell/">Get Microsoft 365 License Usage Count Using PowerShell</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Keeping an eye on the available licenses in your Microsoft tenant is essential to ensuring you and your users have what is needed to keep the business running. Whether you assign licenses directly or you use <a href="https://thesysadminchannel.com/assign-group-based-licensing-in-azure-ad/" rel="noopener" target="_blank">Group Based Licensing</a>, if a user needs a specific license, there shouldn&#8217;t be any hiccups when assigning.  Today I am going to share a PowerShell script to get Microsoft 365 license usage count using PowerShell and Graph API.</p>
<div id="tableofcontents">
<h2>Table Of Contents</h2>
<ul>
<li><a href="#requirements">Requirements</a></li>
<li><a href="#powershell">Get Microsoft 365 License Usage Count Using PowerShell</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ul>
</div>
<div id="requirements" style="scroll-margin-top: 10px;"></div>
<h2>Requirements</h2>
<p>In order to query license information for your tenant, you will need the following API Scopes permitted.</p>
<ul>
<li>Microsoft.Graph or Microsoft.Graph.Beta PowerShell modules</li>
<li>Directory.Read.All or Organization.Read.All</li>
</ul>
<p>&nbsp;</p>
<div id="powershell" style="scroll-margin-top: 10px;"></div>
<h2>Get Microsoft 365 License Usage Count Using PowerShell</h2>
<p>Before we get into the PowerShell script, I wanted to point out that the Microsoft API&#8217;s don&#8217;t show the friendly display names for these licenses.  Instead, they use a SkuPartNumber to give you an idea of what the licenses is regarding.  The problem here is that you also won&#8217;t find the SkuPartNumber anywhere in the portal so it&#8217;s kind of a pain to make sure the license you&#8217;re targeting in the API is in fact the license in the Azure portal.<br />
&nbsp;</p>
<p>Luckily, there is a Microsoft Doc that has this information but it&#8217;s not always up to date.  The link to that doc is <a href="https://learn.microsoft.com/en-us/entra/identity/users/licensing-service-plan-reference" rel="noopener" target="_blank">https://learn.microsoft.com/en-us/entra/identity/users/licensing-service-plan-reference</a>.  There&#8217;s about 400+ Sku&#8217;s that are shown so it&#8217;s also nice that they have provided a csv file that we can use PowerShell to be able to pull these names into our Script.  </p>
<pre class="brush: powershell; title: ; notranslate">
$LicenseFile = 'C:\temp\m365license.csv'
$CutoffDate = (Get-Date).AddDays(-7)

if (Test-Path $LicenseFile) {
    $LastWriteTime = Get-ChildItem -Path $LicenseFile | select -ExpandProperty LastWriteTime

    if ($CutoffDate -gt $LastWriteTime) {
        #csv file is older than a week old.  Let us get a newer version
        Invoke-WebRequest -Uri 'https://download.microsoft.com/download/e/3/e/e3e9faf2-f28b-490a-9ada-c6089a1fc5b0/Product%20names%20and%20service%20plan%20identifiers%20for%20licensing.csv' -OutFile C:\temp\m365license.csv
    }
} else {
    #csv file was not found so let us download it now
    Invoke-WebRequest -Uri 'https://download.microsoft.com/download/e/3/e/e3e9faf2-f28b-490a-9ada-c6089a1fc5b0/Product%20names%20and%20service%20plan%20identifiers%20for%20licensing.csv' -OutFile C:\temp\m365license.csv
}

$csvList = Import-Csv C:\temp\m365license.csv
$LicenseHash = @{}

$csvList | ForEach-Object {
    if (-not $LicenseHash[$_.Guid]) {
        $LicenseHash.Add($_.GUID, $_.Product_Display_Name)
    }
}

$LicenseList = Get-MgSubscribedSku

#Uncomment if you only want to display licenses that are maxed out
foreach ($License in $LicenseList) {
    if ($License.PrepaidUnits.Enabled -ge 1) {
        #if ($License.ConsumedUnits -ge $License.PrepaidUnits.Enabled) {
            [PSCustomObject]@{
                LicenseName   = $LicenseHash[$License.SkuId]
                SkuPartNumber = $License.SkuPartNumber
                SkuId         = $License.SkuId
                Remaining     = $License.PrepaidUnits.Enabled - $License.ConsumedUnits
                Enabled       = $License.PrepaidUnits.Enabled
                Used          = $License.ConsumedUnits
            }
        #}
    }
}
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2023/11/License-Count-Usage-PowerShell-Graph-API.png" target="_blank" rel="noopener"><img fetchpriority="high" decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2023/11/License-Count-Usage-PowerShell-Graph-API.png" alt="Microsoft 365 License Usage Count PowerShell Graph API" width="1019" height="416" class="aligncenter size-full wp-image-4929" srcset="https://thesysadminchannel.com/wp-content/uploads/2023/11/License-Count-Usage-PowerShell-Graph-API.png?v=1699669161 1019w, https://thesysadminchannel.com/wp-content/uploads/2023/11/License-Count-Usage-PowerShell-Graph-API-768x314.png?v=1699669161 768w" sizes="(max-width: 1019px) 100vw, 1019px" /></a><br />
&nbsp;</p>
<p>As you can see from above, the Identity Governance P2 Step Up license has not been updated in the downloadable csv file so the license name shows up blank.</p>
<div id="conclusion" style="scroll-margin-top: 10px;"></div>
<h2>Conclusion</h2>
<p>Hopefully this article was able to help you get Microsoft 365 License usage count using PowerShell and Graph API.  Sometimes we&#8217;re too busy to manually keep an eye on it so having this script along with an email alert would be helpful for preventing your licenses being maxed out.</p>
<p>The post <a href="https://thesysadminchannel.com/get-microsoft-365-license-usage-count-using-powershell/">Get Microsoft 365 License Usage Count Using PowerShell</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/get-microsoft-365-license-usage-count-using-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4920</post-id>	</item>
	</channel>
</rss>
