Skip to content

Get-IntuneDeviceLogin

SYNOPSIS

Retrieves logged-on user info for an Intune-managed device by DeviceId, DeviceName, UserPrincipalName, or UserId.

SYNTAX

ById (Default)

Get-IntuneDeviceLogin -DeviceId <string> [<CommonParameters>]

ByName

Get-IntuneDeviceLogin -DeviceName <string> [<CommonParameters>]

ByUserPrincipalName

Get-IntuneDeviceLogin -UserPrincipalName <string> [<CommonParameters>]

ByUserId

Get-IntuneDeviceLogin -UserId <string> [<CommonParameters>]

ALIASES

This cmdlet has the following aliases, {{Insert list of aliases}}

DESCRIPTION

Uses Microsoft Graph (beta) to read managed device metadata and the usersLoggedOn collection. When given a DeviceId, queries that specific device. When given a DeviceName, resolves one or more matching managed devices (deviceName eq '<name>') and returns logon info for each match. When given a UserPrincipalName or UserId, searches all managed devices and returns only those where the specified user has logged in.

Requires an authenticated Graph session with appropriate scopes.

Scopes (minimum): - DeviceManagementManagedDevices.Read.All - User.Read.All

EXAMPLES

EXAMPLE 1

Connect-MgGraph -Scopes "DeviceManagementManagedDevices.Read.All","User.Read.All" Get-IntuneDeviceLogin -DeviceId "c1f5d1d7-2d2b-4d8c-9f0a-0d2a3d1e2f3a"

Gets logged-on user info for the specified device.

EXAMPLE 2

Get-IntuneDeviceLogin -DeviceName PC-001

Resolves the device name and returns logged-on user info for the match.

EXAMPLE 3

"

Returns all devices where the specified user principal name has logged in.

EXAMPLE 4

Get-IntuneDeviceLogin -UserId "c1f5d1d7-2d2b-4d8c-9f0a-0d2a3d1e2f3a"

Returns all devices where the specified user (by ID) has logged in.

PARAMETERS

-DeviceId

The Intune managed device identifier (GUID). Parameter set: ById.

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases:
- Id
- ManagedDeviceId
ParameterSets:
- Name: ById
  Position: Named
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-DeviceName

The device name to resolve in Intune managed devices. Parameter set: ByName. If multiple devices share the same name, all matches are processed.

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases:
- Name
- ComputerName
ParameterSets:
- Name: ByName
  Position: Named
  IsRequired: true
  ValueFromPipeline: true
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-UserId

The Entra ID user object identifier (GUID). Parameter set: ByUserId. Returns all devices where this user has logged in.

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: ByUserId
  Position: Named
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-UserPrincipalName

The user principal name (UPN) to search for across all managed devices. Parameter set: ByUserPrincipalName. Returns all devices where this user has logged in.

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases:
- UPN
ParameterSets:
- Name: ByUserPrincipalName
  Position: Named
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.String (DeviceId

{{ Fill in the Description }}

System.String

{{ Fill in the Description }}

OUTPUTS

PSCustomObject with the following properties

  • DeviceId (string)
  • DeviceName (string)
  • OperatingSystem (string)
  • UserId (string)
  • UserPrincipalName (string)
  • LastLogonDateTime (datetime)

{{ Fill in the Description }}

System.Management.Automation.PSObject

{{ Fill in the Description }}

NOTES

Author: FHN & ChatGPT & GitHub Copilot - Uses /beta Graph endpoints because usersLoggedOn is exposed there.

{{ Fill in the related links here }}