How about something simple then?
$date = (get-date).AddDays(-30)
$Params = @{
Filter = "Enabled = $true -and LastLogonDate -lt $date"
Properties = "LastLogonDate"
}
$Props = "Name","LastLogonDate","'DistinguishedName"
$Inactive = Get-Aduser @Params | Select-Object $Props
Keep in mind that the LastLogonDate isn't replicated immediately between DCs. The replication happens at a random time between 9 and 14 days. You may not find all the users on the first pass, but you'll find them eventually.