Skip to content

Enganga/get msidinactivesigninuser #1438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

emmanuel-karanja
Copy link
Collaborator

Porting of MSIdentityTools 'Get-MsIdInactiveSignInUser' to GA and Beta Entra PowerShell.

@emmanuel-karanja emmanuel-karanja requested a review from a team as a code owner April 2, 2025 13:10
Copy link

Learn Build status updates of commit d778da9:

✅ Validation status: passed

File Status Preview URL Details
module/docs/entra-powershell-beta/Users/Get-EntraBetaInactiveSignInUser.md ✅Succeeded View (entra-powershell-beta-preview)
module/docs/entra-powershell-v1.0/Users/Get-EntraInactiveSignInUser.md ✅Succeeded View (entra-powershell-preview)
module/Entra/Microsoft.Entra/Users/Get-EntraInactiveSignInUser.ps1 ✅Succeeded
module/EntraBeta/Microsoft.Entra.Beta/Users/Get-EntraBetaInactiveSignInUser.ps1 ✅Succeeded
test/Entra/Users/Get-EntraInactiveSignInUser.Tests.ps1 ✅Succeeded
test/EntraBeta/Users/Get-EntraBetaInactiveSignInUser.Tests.ps1 ✅Succeeded

For more details, please refer to the build report.

For any questions, please:

@emmanuel-karanja emmanuel-karanja added Ready For Review The PR Ready for Review P0 Highest priority labels Apr 3, 2025
# User Last Sign In Activity is before Days ago
[Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 1)]
[Alias("BeforeDaysAgo")]
[int] $LastSignInBeforeDaysAgo = 30,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this paramater seems to be mandatory but has a default value of 30, should the [ValidateRange(30, [int]::MaxValue)] attribute be better used here?

$uri = "/beta/users?`$filter=$inactiveFilter&`$select=signInActivity,UserPrincipalName,Id,DisplayName,mail,userType,createdDateTime,accountEnabled"

Write-Debug ("Retrieving Users with Filter {0}" -f $inactiveFilter)
$queryUsers = (Invoke-GraphRequest -Method GET -Uri $uri -Headers $customHeaders).value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be filtered at the API level instead of client-side?

Copy link
Collaborator

@DButoyez DButoyez Apr 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e

if ($UserType -ne "All") {
$inactiveFilter = "($inactiveFilter) and (userType eq '$UserType')"
}

Then just use the results directly
$users = (Invoke-GraphRequest -Method GET -Uri $uri -Headers $customHeaders).value

[OutputType([string])]
param (
# User Last Sign In Activity is before Days ago
[Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 1)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this paramater seems to be mandatory but has a default value of 30, should the [ValidateRange(30, [int]::MaxValue)] attribute be better to use here?

"Member" { $users = $queryUsers | Where-Object { $_.userType -eq 'Member' } }
"Guest" { $users = $queryUsers | Where-Object { $_.userType -eq 'Guest' } }
"All" { $users = $queryUsers }
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be filtered at the API level instead of client-side?
i.e

if ($UserType -ne "All") {
$inactiveFilter = "($inactiveFilter) and (userType eq '$UserType')"
}

Then just use the results directly
$users = (Invoke-GraphRequest -Method GET -Uri $uri -Headers $customHeaders).value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P0 Highest priority Ready For Review The PR Ready for Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants