What am i doing wrong?
I need to get all users which did not sign in interactively on noninteractively in the last 425 days. For this i need to look at two attributes:
LastSignInDateTime
LastNonInteractiveSignInDateTime
I also want to filter out all objects where the invite has been sent this year.
My arrays conains folliwing objects
PS C:\VSCode\PS> $UnfilteredStaleAccounts | Get-Member -MemberType Noteproperty | select Name
Name
----
CreatedDateTime
DisplayName
ExternalUserState
Id
LastNonInteractiveSignInDateTime
LastSignInDateTime
You use â-orâ and â-andâ without explicite priority, I means, without parenthesis that put explicite priority of â-andâ and â-orâ.
I think you may look at that !
Donât think this part will ever be true
(Get-Date).Year is an int
CreatedDateTime is either a string or datetime object??? If itâs a datetime or converted to one then you could say
Simplify your approach. Instead of stringing together a more complicated where-object scriptblock, filter out the accounts that were created this year. Itâs not only going to make it easier for you to write, but itâll make it easier for someone else to read later down the road. You also should be careful using the notlike on the date like that. No reason to do that if you have a datetime object to begin with, you can simply check the Year property and see if it matches the current year, if it doesnât you can exclude it. For example:
But the array staleguest still contains objects which are newer then 425 days ago.
I have checked the noteproperties, and both LastSignInDateTime and LastNonInteractiveSignInDateTime are listed as System.DateTime