# Retrieve Active Directory computer properties such as LastLogonDate.
# The list of machine need to be added in hosts.txt file in script folder
# The result will be saved to Output.csv file in script folder.
Import-Module ActiveDirectory
$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path
$input = $directorypath + "\host.txt"
$output = $directorypath + "\output.csv"
Get-Content $input | ForEach-Object {
Get-ADComputer $_ -Properties * | Select-Object Name,LastLogonDate,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion,WhenCreated,Description
} | Export-Csv $output
Related Posts:
- Powershell – Get System up time
- Powershell Script : List AD Organizational Unit and GPOs linked to them
- Powershell – Compare hardware and software details on two computers
- Powershell Script : Retrieve AD Computers Properties
- Powershell – Merge CSV files & Insert file name as a column
- Powershell Script: Validate if Computer account exists in Active Directory
- Powershell remote – WinRM cannot complete the operation
- Powershell script to Add bulk users / computers to AD Group
- PowerShell Script : Copy AD Group Membership
- Using PowerShell Behind a Proxy Server