PowerShell Active Directory

email me

# Load the Microsoft Active Directory Module
Import-Module ActiveDirectory

# Get a list of computers that have WIN7 in their name
$Computers = Get-ADComputer -Filter "Name -like '*WIN7*'" | ForEach-Object {$_.Name}

# Get a list of all computer names
$Computers = Get-ADComputer -Filter * | ForEach-Object {$_.Name}

# Get a list of fully qualified host names
$Computers = Get-ADComputer -Filter * | ForEach-Object {$_.DNSHostName}

# Load the Quest Active Directory cmdlets
Add-PSSnapin Quest.ActiveRoles.ADManagement

# Get a list of computers running the Windows Server 2008 operating system
$Computers = Get-QADComputer -OSName "Windows Server 2008*" | ForEach-Object {$_.Name}

# Get a list of computers that are members of the Database Servers group
$Computers = Get-QADComputer -MemberOf 'Database Servers' | ForEach-Object {$_.Name}

# Get a list of computers that are located in the Domain Controllers OU
$Computers = Get-QADComputer -SearchRoot "testlab.local/Domain Controllers" | ForEach-Object {$_.Name}