I'm trying to read some device names from a .csv and compare them with AzureAD. The .csv in question only has one column with device names. Building the code from here: https://docs.microsoft.com/en-us/azure/active-directory/devices/manage-stale-devices
I'm modifying their code here:
$dt = (Get-Date).AddDays(-90)
Get-AzureADDevice -All:$true | Where {$_.ApproximateLastLogonTimeStamp -le $dt} | select-object -Property AccountEnabled, DeviceId, DeviceOSType, DeviceOSVersion, DisplayName, DeviceTrustType, ApproximateLastLogonTimestamp | export-csv devicelist-olderthan-90days-summary.csv -NoTypeInformation
Currently, my code looks like this:
$dt = (Get-Date).AddDays(-90)
$Names = @()
Import-Csv -Path C:\test123\Computers.csv | ForEach-Object {$Names += $_.Name}
Get-AzureADDevice -All:$true | Where {($_.ApproximateLastLogonTimeStamp -le $dt) -and ($_.DisplayName -eq $Names)} | select-object -Property DisplayName, ApproximateLastLogonTimestamp | export-csv oldcomputers.csv -NoTypeInformation
However, the csv that's created is blank. Is there some issue with how I'm searching the local .csv file?