MS Graph SignInActivity Attribute missing?

Viewed 1814

I'm quite confused by the documentation that's uploaded to the MS site,

I'm working on auditing inactive users within Azure AD, yet when I follow the below two links I cannot for the life of me find the attribute "signinactivity" with my Graph API reponses:

Any help with this? Has the feature been taken out?

Apologies for my ignorance, but I'm confused that I've followed the documentation instructions yet the results are not there when I execute.

$response = Invoke-RestMethod -Method POST -Uri "https://login.microsoftonline.com/{tenant_ID}/oauth2/v2.0/token" -Body $postParams
$token = ConvertTo-SecureString -String $response.access_token  -AsPlainText -Force
$query = Invoke-RestMethod -Method GET -Authentication Bearer -Token  $token -Uri "https://graph.microsoft.com/beta/users?$select=displayName,userPrincipalName,signInActivity"
1 Answers

It appears your $select expression is ignored since PowerShell tries to expand $ into a variable. A $ prefix needs to be escaped, in PowerShell with "`" (backward apostrophe/grave) character:

$requestUrl = "https://graph.microsoft.com/beta/users?`$select=displayName,userPrincipalName,signInActivity"
$query = Invoke-RestMethod -Method GET -Authentication Bearer -Token  $token -Uri $requestUrl

Option 2

Alternately you could enclose string expression in single quotes ' instead of double quotes " (in that case $ prefix does not need to be escaped):

$requestUrl = 'https://graph.microsoft.com/beta/users?$select=displayName,userPrincipalName,signInActivity'

Option 3

Since on the beta endpoint, the $ prefix is optional instead of $select you can specify select:

$requestUrl = "https://graph.microsoft.com/beta/users?select=displayName,userPrincipalName,signInActivity"
Related