I'm trying to get a list of serial numbers of devices via PowerShell with the below command where the Serial Number isn't blank and the DeviceName and ManagedDeviceName don't have "MOB-" in them. I can do this with the below command:
Get-IntuneManagedDevice -filter "manufacturer eq 'Apple'" | Get-MSGraphAllPages | Where-Object -Property issupervised -eq True | Where-object { $_.devicename -notlike "*MOB-*" -or $_.manageddevicename -notlike "*MOB*" -and $_.serialnumber -ne $Null -and $_.serialnumber -ne ""} | Select serialnumber
That works well enough. But what I also want to do is only show the devices where the "lastsyncdatetime" is today. I've tried doing the below (As an example of todays date) but that doesn't return anything at all:
Get-IntuneManagedDevice -filter "manufacturer eq 'Apple'" | Get-MSGraphAllPages | Where-Object -Property issupervised -eq True | Where-object { $_.devicename -notlike "*MOB-*" -or $_.manageddevicename -notlike "*MOB*" -and $_.serialnumber -ne $Null -and $_.serialnumber -ne "" -and $_.lastsyncdatetime -like "*23/06/2023*"} | Select serialnumber
For reference, if I select the "lastsyncdatetime" attribute, the date is in the format of DD/MM/YYYY HH:MM:SS. Even if I don't do an asterisk and search for the exact date and time, it still doesn't show the entry.