<?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>Get-AzureADAuditSignInLogs Archives - the Sysadmin Channel</title>
	<atom:link href="https://thesysadminchannel.com/tag/get-azureadauditsigninlogs/feed/" rel="self" type="application/rss+xml" />
	<link>https://thesysadminchannel.com/tag/get-azureadauditsigninlogs/</link>
	<description>Documenting My Life as a System Administrator</description>
	<lastBuildDate>Thu, 15 Jul 2021 07:09:08 +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 Azure AD Last Login Date And Sign-In Activity</title>
		<link>https://thesysadminchannel.com/get-azure-ad-last-login-date-and-sign-in-activity/</link>
					<comments>https://thesysadminchannel.com/get-azure-ad-last-login-date-and-sign-in-activity/#comments</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Thu, 15 Jul 2021 07:09:08 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[azure ad last logon date powershell]]></category>
		<category><![CDATA[azure ad last logon powershell]]></category>
		<category><![CDATA[azure ad user last logon time powershell]]></category>
		<category><![CDATA[Azure last login report PowerShell]]></category>
		<category><![CDATA[Get Azure AD Last Login Date]]></category>
		<category><![CDATA[Get-AzureADAuditSignInLogs]]></category>
		<category><![CDATA[powershell get azure ad user last logon time]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=3276</guid>

					<description><![CDATA[<p>Every so often when I run an audit on my environment, I&#8217;m always finding myself needing to check recent activity logs to specifically get Azure AD last login date and sign-in activity. If you recall, I wrote a previous post&#8230; <a href="https://thesysadminchannel.com/get-azure-ad-last-login-date-and-sign-in-activity/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/get-azure-ad-last-login-date-and-sign-in-activity/">Get Azure AD Last Login Date And Sign-In Activity</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Every so often when I run an audit on my environment, I&#8217;m always finding myself needing to check recent activity logs to specifically <strong>get Azure AD last login date and sign-in activity</strong>.  If you recall, I wrote a previous post to <a href="https://thesysadminchannel.com/get-last-logon-date-for-all-users-in-your-domain/" rel="noopener" target="_blank">Get Last Logon Date For All Users in Your Domain</a>, but that script is specifically for Onprem Active Directory domain activity.</p>
<p>In this instance, we&#8217;re going to focus our efforts on compiling an Azure last login report using PowerShell.  Our report would include something similar to the following:</p>
<ul>
<li><strong>CreatedDateTime</strong>: Date and Time of when the sign-in occurred</li>
<li><strong>UserPrincipalName</strong>: UPN of the user</li>
<li><strong>IsInteractive</strong>: Whether or not the user signed in manually, or if it was through automation</li>
<li><strong>AppDisplayName</strong>: Which app the user was logging into</li>
<li><strong>IpAddress</strong>: In some instances it will display the public IP, or internal IP</li>
<li><strong>TokenIssuerType</strong>: If the authentication happened in ADFS or Azure AD</li>
<li><strong>DeviceOS</strong>: The operating system of the device</li>
</ul>
<p>You can also add properties to determine the City/State location, device detail such as System OS and what client was being used.  The information that is provided is very rich and it&#8217;s up to you to choose what suits your needs.</p>
<p>The great thing is that you don&#8217;t need to re-invent the wheel because the Azure AD module already has a cmdlet that encompasses all of the information that I mentioned above.  That command is <strong>Get-AzureADAuditSignInLogs</strong></p>
<h2>Get Azure AD Last Login Date And Sign-In Activity in Azure Portal</h2>
<p>There are methods of getting the information that we need, and those 2 methods are the GUI method as well as the Powershell method.  We&#8217;ll focus on the GUI method first.</p>
<ul>
<li>Navigate to <a href="https://portal.azure.com" rel="noopener" target="_blank">https://portal.azure.com</a> -> Azure AD -> User you want to check -> Sign-Ins</li>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/07/Sign-in-Logs-Azure-Portal.png" target="_blank" rel="noopener"><img fetchpriority="high" decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/07/Sign-in-Logs-Azure-Portal.png" alt="Sign in Logs Azure Portal" width="1513" height="654" class="aligncenter size-full wp-image-3280" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/07/Sign-in-Logs-Azure-Portal.png?v=1626325231 1513w, https://thesysadminchannel.com/wp-content/uploads/2021/07/Sign-in-Logs-Azure-Portal-1024x443.png?v=1626325231 1024w, https://thesysadminchannel.com/wp-content/uploads/2021/07/Sign-in-Logs-Azure-Portal-768x332.png?v=1626325231 768w" sizes="(max-width: 1513px) 100vw, 1513px" /></a></p>
</ul>
<p>The GUI is probably preferred when you need to check a handful of users, but as you can see this option is not very scalable.  For batch processing, we&#8217;ll turn over to trusty Powershell.</p>
<h2>Get Azure AD Last Login Report Using PowerShell</h2>
<p>As I mentioned already, if we want to scale this operation, the GUI is simply not going to cut it.  Just think how long it will take to check 100 users,  10,000?  yeah not happening.  The good thing is that it&#8217;s relatively easy to do it using PS.</p>
<p>In my example, I&#8217;m going to check Buzz Lightyear as we did in the GUI just to confirm that the data we&#8217;re pulling is the same. I should mention that you&#8217;ll need to download the Azure AD (or Azure AD Preview) module.  I, myself, like to use the Azure AD Preview module.</p>
<pre class="brush: powershell; title: ; notranslate">

#Import the Azure AD Module
Import-Module AzureADPreview

#Connect to Azure AD
Connect-AzureAD -AccountId AzureAdmin@thesysadminchannel.com

Get-AzureADAuditSignInLogs -Filter &quot;UserPrincipalName eq 'blightyear@thesysadminchannel.com'&quot; -Top 1 | `
select CreatedDateTime, UserPrincipalName, IsInteractive, AppDisplayName, IpAddress, TokenIssuerType, @{Name = 'DeviceOS'; Expression = {$_.DeviceDetail.OperatingSystem}}
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/07/Get-AzureADAuditSignInLogs-Example.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/07/Get-AzureADAuditSignInLogs-Example.png" alt="Get-AzureADAuditSignInLogs Example" width="1099" height="422" class="aligncenter size-full wp-image-3284" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/07/Get-AzureADAuditSignInLogs-Example.png?v=1626329023 1099w, https://thesysadminchannel.com/wp-content/uploads/2021/07/Get-AzureADAuditSignInLogs-Example-1024x393.png?v=1626329023 1024w, https://thesysadminchannel.com/wp-content/uploads/2021/07/Get-AzureADAuditSignInLogs-Example-768x295.png?v=1626329023 768w" sizes="(max-width: 1099px) 100vw, 1099px" /></a></p>
<p>&nbsp;</p>
<p>The above works great for checking a single user or multiple users.  If we wanted to check more users, we would either need the UPN or ObjectId of that user and do a foreach loop.  Here&#8217;s what that would look like.</p>
<pre class="brush: powershell; title: ; notranslate">
$UPNList = 'blightyear@thesysadminchannel.com', 'astark@thesysadminchannel.com', 'jsnow@thesysadminchannel.com'

foreach ($User in $UPNList) {
    Get-AzureADAuditSignInLogs -Filter &quot;UserPrincipalName eq '$User'&quot; -Top 1 | `
    select CreatedDateTime, UserPrincipalName, IsInteractive, AppDisplayName, IpAddress, TokenIssuerType, @{Name = 'DeviceOS'; Expression = {$_.DeviceDetail.OperatingSystem}}
}
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2021/07/Get-AzureADAuditSignInLogs-foreach-loop-example.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2021/07/Get-AzureADAuditSignInLogs-foreach-loop-example.png" alt="Get-AzureADAuditSignInLogs foreach loop example" width="1099" height="632" class="aligncenter size-full wp-image-3287" srcset="https://thesysadminchannel.com/wp-content/uploads/2021/07/Get-AzureADAuditSignInLogs-foreach-loop-example.png?v=1626330788 1099w, https://thesysadminchannel.com/wp-content/uploads/2021/07/Get-AzureADAuditSignInLogs-foreach-loop-example-1024x589.png?v=1626330788 1024w, https://thesysadminchannel.com/wp-content/uploads/2021/07/Get-AzureADAuditSignInLogs-foreach-loop-example-768x442.png?v=1626330788 768w" sizes="(max-width: 1099px) 100vw, 1099px" /></a></p>
<h2>Conclusion</h2>
<p>So there you have it,  hopefully you found this article to get Azure AD last login date and sign-in activity useful and something you might be able to use in your org.  Thankfully, the folks at Microsoft and Azure have this readily and easily available.  If you like articles like this, be sure to check out our <a href="https://thesysadminchannel.com/azure/" rel="noopener" target="_blank">Azure</a> category for more information on MS cloud.  If you&#8217;re more into video learning, check out our <a href="https://www.youtube.com/c/theSysadminChannel" rel="noopener" target="_blank">Youtube Page</a> for awesome sysadmin content.</p>
<p>The post <a href="https://thesysadminchannel.com/get-azure-ad-last-login-date-and-sign-in-activity/">Get Azure AD Last Login Date And Sign-In Activity</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/get-azure-ad-last-login-date-and-sign-in-activity/feed/</wfw:commentRss>
			<slash:comments>11</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3276</post-id>	</item>
	</channel>
</rss>
