<?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>Reprocess User License Assignments Archives - the Sysadmin Channel</title>
	<atom:link href="https://thesysadminchannel.com/tag/reprocess-user-license-assignments/feed/" rel="self" type="application/rss+xml" />
	<link>https://thesysadminchannel.com/tag/reprocess-user-license-assignments/</link>
	<description>Documenting My Life as a System Administrator</description>
	<lastBuildDate>Thu, 24 Mar 2022 01:03:45 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
<site xmlns="com-wordpress:feed-additions:1">144174110</site>	<item>
		<title>Reprocess User License Assignments using Graph API and PowerShell</title>
		<link>https://thesysadminchannel.com/reprocess-user-license-assignments-using-graph-api-and-powershell/</link>
					<comments>https://thesysadminchannel.com/reprocess-user-license-assignments-using-graph-api-and-powershell/#respond</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Thu, 24 Mar 2022 01:03:45 +0000</pubDate>
				<category><![CDATA[Graph API]]></category>
		<category><![CDATA[Invoke-MgLicenseUser]]></category>
		<category><![CDATA[Reprocess User License Assignments]]></category>
		<category><![CDATA[reprocessLicenseAssignment]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=3812</guid>

					<description><![CDATA[<p>If you&#8217;ve followed along and are receptive to Microsoft best practices, you should be aware that using group based licensing in Azure AD is the go-to method for assigning licenses to your users in the cloud. I must say, group-based&#8230; <a href="https://thesysadminchannel.com/reprocess-user-license-assignments-using-graph-api-and-powershell/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/reprocess-user-license-assignments-using-graph-api-and-powershell/">Reprocess User License Assignments using Graph API and PowerShell</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If you&#8217;ve followed along and are receptive to Microsoft best practices, you should be aware that using <a href="https://thesysadminchannel.com/assign-group-based-licensing-in-azure-ad/" rel="noopener" target="_blank">group based licensing in Azure AD</a> is the go-to method for assigning licenses to your users in the cloud.  I must say, group-based licensing is definitely much easier to manage but it does have some draw backs.  I listed those in the article above, but today we&#8217;ll focus on learning how to reprocess user license assignments using Graph API and Powershell should an issue arise with conflicting licenses.</p>
<div id="tableofcontents">
<h2>Table Of Contents</h2>
<ul>
<li><a href="#requirements">Requirements</a></li>
<li><a href="#reprocessgroup">Reprocess Users at the Group Level</a></li>
<li><a href="#reprocessuser">Reprocess User License Assignments using Graph API and PowerShell</a></li>
<ul>
<li><a href="#powershellsdk">Use the Microsoft.Graph Powershell SDK module</a></li>
<li><a href="#restapi">Use the REST API directly</a></li>
</ul>
<li><a href="#conclusion">Conclusion</a></li>
</ul>
</div>
<div id="requirements" style="scroll-margin-top: 15px;"></div>
<h2>Requirements</h2>
<p>Since this will utilize Graph API to drive these requests, you&#8217;ll need the following rights on the Service Principal or account that&#8217;s making the modification.</p>
<ul>
<li>User.ReadWrite.All and Directory.ReadWrite.All Permissions</li>
<li>Azure AD P1/P2 is needed for Group Based Licensing</li>
</ul>
<p>&nbsp;</p>
<div id="blockquote1">
If you want to get started on learning how to use Microsoft Graph API, be sure to check out <a href="https://thesysadminchannel.com/how-to-connect-to-microsoft-graph-api-using-powershell/" rel="noopener" target="_blank">How To Connect To Microsoft Graph API Using PowerShell</a>.</p>
<p>This should get you up and running with zero previous working knowledge.
</p></div>
<div id="reprocessgroup" style="scroll-margin-top: 15px;"></div>
<h2>Reprocess Users at the Group Level</h2>
<p>Before we get started, I should preface this by saying that I am well aware that there is a way to reprocess the licenses at the group level.  However,  if you work in a large organization with tens of thousands of users in a group, this may take more time than what&#8217;s needed.<br />
&nbsp;</p>
<p>Also, in the event that you only need to reprocess a handful of users instead of the masses that are in the group, this would tend to make more sense.</p>
<div id="attachment_3975" style="width: 973px" class="wp-caption aligncenter"><a href="https://thesysadminchannel.com/wp-content/uploads/2022/03/Reprocess-user-license.png" target="_blank" rel="noopener"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-3975" src="https://thesysadminchannel.com/wp-content/uploads/2022/03/Reprocess-user-license.png" alt="Reprocess License by Group" width="963" height="427" class="size-full wp-image-3975" srcset="https://thesysadminchannel.com/wp-content/uploads/2022/03/Reprocess-user-license.png?v=1648003395 963w, https://thesysadminchannel.com/wp-content/uploads/2022/03/Reprocess-user-license-768x341.png?v=1648003395 768w" sizes="(max-width: 963px) 100vw, 963px" /></a><p id="caption-attachment-3975" class="wp-caption-text">Reprocessing done at the group level</p></div>
<p>&nbsp;</p>
<div id="reprocessuser" style="scroll-margin-top: 15px;"></div>
<h2>Reprocess User License Assignments using Graph API and PowerShell</h2>
<p>Now that we know how to connect to Graph API and opted to reprocess at the user level instead of the group level, let&#8217;s learn how to use Powershell so you can programmatically reprocess licenses on the user level.<br />
&nbsp;</p>
<p>This can be done using the Microsoft.Graph Powershell SDK module or calling the REST API directly. </p>
<div id="powershellsdk" style="scroll-margin-top: 15px;"></div>
<h3>Use the Microsoft.Graph Powershell SDK module</h3>
<p>When using the Microsoft.Graph Powershell SDK you only need to use a single cmdlet.</p>
<pre class="brush: powershell; title: ; notranslate">
Import-Module Microsoft.Graph.Users.Actions

Invoke-MgLicenseUser -UserId $userId
</pre>
<div id="restapi" style="scroll-margin-top: 15px;"></div>
<h3>Use the REST API directly</h3>
<p>If you want to call the REST API directly, you can simply do this.</p>
<pre class="brush: powershell; title: ; notranslate">
Invoke-MgGraphRequest -Uri &quot;https://graph.microsoft.com/v1.0/users/$userid/reprocessLicenseAssignment&quot; -Method POST -ContentType application/json -Body &quot;$null&quot;
</pre>
<p>&nbsp;</p>
<p>Since I&#8217;m a Powershell enthusiast and I love making scripts, I also wrote a wrapper before I knew the SDK command was available.  So, in the spirit of sharing, I&#8217;ll post that code here.</p>
<pre class="brush: powershell; title: ; notranslate">
Function Invoke-MsGraphReprocessLicenseAssignment {
&lt;#
.SYNOPSIS
    Reprocess a user's license assignment using Graph Api


.NOTES
    Name: Invoke-MsGraphReprocessLicenseAssignment
    Author: Paul Contreras
    Version: 1.0
    DateCreated: 2021-Jan-20


.EXAMPLE
    Invoke-MsGraphReprocessLicenseAssignment -UserId username@domain.com

.LINK
    https://thesysadminchannel.com/reprocess-user-license-assignments-using-graph-api-and-powershell/ -

#&gt;

    [CmdletBinding(
        SupportsShouldProcess,
        ConfirmImpact='Medium'
    )]
    param(
        [Parameter(
            Mandatory = $true,
            ValueFromPipeline = $true,
            ValueFromPipelineByPropertyName = $true
        )]
        [Alias('UserPrincipalName')]
        [string[]]  $UserId
    )

    BEGIN {}

    PROCESS {
        foreach ($User in $UserId) {
            try {
                $GraphUser = Get-MgUser -UserId $User | select -ExpandProperty Id

                if ($PSCmdlet.ShouldProcess(&quot;Reprocessing license assignments for: $User&quot;) ) {
                    $Reprocess = Invoke-MgGraphRequest -Uri &quot;https://graph.microsoft.com/v1.0/users/$GraphUser/reprocessLicenseAssignment&quot; -Method POST -ContentType application/json -Body &quot;$null&quot; -ErrorAction Stop

                    [PSCustomObject]@{
                        Id                = $Reprocess['id']
                        DisplayName       = $Reprocess['displayName']
                        UserPrincipalName = $Reprocess['userPrincipalName']
                        JobTitle          = $Reprocess['jobTitle']
                    }
                }

            } catch {
                Write-Error $_.Exception.Message

            }
        }
    }

    END {}
}
</pre>
<div id="conclusion" style="scroll-margin-top: 15px;"></div>
<h2>Conclusion</h2>
<p>Hopefully this article was able to clearly show you how to reprocess user license assignments using Graph API and PowerShell.  It&#8217;s been a great help to be able to reprocess users on a individual level without having to shake the bucket for thousands of users when it&#8217;s not needed.</p>
<p>The post <a href="https://thesysadminchannel.com/reprocess-user-license-assignments-using-graph-api-and-powershell/">Reprocess User License Assignments using Graph API and PowerShell</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/reprocess-user-license-assignments-using-graph-api-and-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3812</post-id>	</item>
	</channel>
</rss>
