$exportPath = "C:\Temp\ADClients_LastLogon.csv" Get-ADComputer -Filter * -Properties LastLogonDate, OperatingSystem, DistinguishedName | Select-Object Name, OperatingSystem, @{Name="LastLogonDate";Expression={$_.LastLogonDate}}, @{Name="DaysInactive";Expression={ if ($_.LastLogonDate) { (New-TimeSpan -Start $_.LastLogonDate -End (Get-Date)).Days } else { "Nie angemeldet" } }}, DistinguishedName | Sort-Object LastLogonDate | Export-Csv -Path $exportPath -NoTypeInformation -Encoding UTF8 -Delimiter ";" Write-Host "Export abgeschlossen: $exportPath"