Need help with output to csv and also need to export ipv4address, managedby attributes within this script
script ouptuts computer name and lastlogon
import-module ActiveDirectory
$dcs = Get-ADComputer -Filter { OperatingSystem -NotLike '*Server*' } `
-Properties OperatingSystem
foreach($dc in $dcs) { `
Get-ADComputer $dc.Name -Properties lastlogontimestamp | `
Select-Object @{n="Computer";e={$_.Name}}, @{Name="Lastlogon"; `
Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp)}}
}
Came up with this :
Get-ADComputer -Filter { OperatingSystem -NotLike '*Server*' } -properties * | `
Select-Object @{n="Computer";e={$_.Name}}, @{Name="lastlogontimestamp";Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp)}}, @{n="IP";e={$_.ipv4address}}, @{n="ManagedBy";e={$_.managedby}}, @{n="Operating System";e={$_.operatingsystem}} | Export-csv C:\users\admin.Remi.Boileau\OSxpTypes1.csv -notypeinformation -encoding utf8
All comments welcomed
Remi