Active Directory computers that are not disabled

This script will retrieve and display all Active Directory computers that are active (i.e., enabled). You can further customize the script to include additional properties or filter criteria as needed.

# Import the Active Directory module
Import-Module ActiveDirectory

# Retrieve all Active Directory computers that are enabled
$computers = Get-ADComputer -Filter {Enabled -eq $true}

# Display the computers
$computers

  1. Import-Module ActiveDirectory: This line imports the Active Directory module, which provides cmdlets for managing Active Directory objects.
  2. Get-ADComputer: This cmdlet is used to retrieve Active Directory computers. We specify a filter using the -Filter parameter to narrow down the results.
  3. {Enabled -eq $true}: This is the filter expression. We’re filtering computers where the Enabled property is equal to $true, indicating they are active.
  4. $computers: This variable stores the result of the Get-ADComputer cmdlet, which contains all the Active Directory computers that meet the specified filter criteria.
  5. $computers: Finally, we display the computers by outputting the contents of the $computers variable.

 

For an advanced version of this PowerShell Script that queries every Active Computer in the Active Directory Domain and exports to CSV, Checkout this link

Leave a Comment