Ways on how to manage azure Devices and Find device location per office

Darren Ramos 40 Reputation points
2024-06-04T13:04:03.4933333+00:00

Hi,

Im on creating some automation to delete all stale devices in Entra ID (not in intune) and i need to find a way to find each device location so i can separate them every office. are there any ways to check the device location or physcial location? im using PowerShell script to do the automation.

Thanks

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,435 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,188 questions
{count} votes

Accepted answer
  1. Navya 5,645 Reputation points Microsoft Vendor
    2024-06-06T13:09:39.4833333+00:00

    Hi @Darren Ramos

    Thank you for posting this in Microsoft Q&A.

    I understand you are looking for a way to manage Azure devices and find their location per office. Unfortunately, there no device location or physical location attribute in an AAD device properties. This location features available in Intune not in Azure.

    One possible way is to via sign in logs. Sign-in logs will be available 30 days. Use below PowerShell to get sign-in logs.

    $SetDate = (Get-Date).AddDays(-30); $SetDate = Get-Date($SetDate) -format yyyy-MM-dd  
    $array = Get-AzureADAuditSignInLogs -Filter "createdDateTime gt $SetDate" 
    
    $data =@()
    foreach($item in $array)
    {
    
       
       $row = "" | Select-Object User,UPN,City,State,Region
       $row.user = $item.UserDisplayName
       $row.upn = $item.UserPrincipalName
       $row.city = $item.Location.City
       $row.state = $item.Location.State
       $row.region = $item.Location.CountryOrRegion
       $data += $row 
    }
    $data | Format-Table -AutoSize
    

    Use below code to separate them every office.

    Get-AzureADAuditSignInLogs -Filter "location/city eq 'Redmond' and location/state eq 'Washington' and location/countryOrRegion eq 'US'"
    
    

    Hope this helps. Do let us know if you any further queries.

    Thanks,

    Navya.

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful