import-module ActiveDirectory
#Set the domain to search at the Server parameter. Run powershell as a user with privilieges in that domain to pass different credentials to the command.
#Searchbase is the OU you want to search. By default the command will also search all subOU's. To change this behaviour, change the searchscope parameter. Possible values: Base, onelevel, subtree
#Ignore the filter and properties parameters
$ADComputerParams=@{
'Server' = 'yourdomaincontroller.domain.com'
'Searchbase' = 'DC=DOMAIN,DC=COM'
'Searchscope'= 'Subtree'
'Filter' = 'name -like "*"'
'Properties' = '*'
}
get-adcomputer @ADComputerParams | select-object 'name', 'operatingSystem', 'managedby', @{n='lastLogonTimestamp';e={[DateTime]::FromFileTime($_.lastLogonTimestamp)}} | export-csv -delimiter ";" ".\DomainComputers.csv"
No comments:
Post a Comment