Get AD Computer Description Using Powershell - MorganTechSpace

Skip to content Menu We can find and get the description of Active Directory computers by using the AD powershell cmdlet Get-ADComputer. In this post, I am going to write powershell script samples to get description of AD computers and get list of computer names based on description.

Before proceed, first run the below command to import Active Directory module.

Import-Module ActiveDirectory

Summary

  • Get description of all AD computers
  • Apply filter to get computers by description
  • Get description of computers from specific OU
  • Get description for list of computers

Get description of all AD computers

The following command find and list the name and description of all the available computers in Active Directory.

Get-ADComputer -Filter * -Property Name,Description | Select -Property Name,Description

You can also export the details to csv file by using the powershell cmdlet Export-CSV.

Get-ADComputer -Filter * -Property Name,DNSHostName,Description | Select -Property Name,DNSHostName,Description | Export-CSV "C:\AllComputers.csv" -NoTypeInformation -Encoding UTF8

Apply filter to get computers by description

The Get-ADComputer cmdlet supports SQL like filter, we can easily use this filter to get only specific set of AD computers. The below script select all the computers whose description contains the text ‘SVR‘.

Get-ADComputer -Filter 'Description -like "*SVR*"' -Property Name,Description | Select -Property Name,Description

Apply LDAP Filter to get set of AD computers:

If your are familiar with LDAP filter, instead of normal filter, you can also use LDAP filter with to select particular set of AD computers.

Get-ADComputer -LDAPFilter '(Description=*SVR*)' -Property Name,Description | Select -Property Name,Description

Get description of computers from specific OU

We can set target OU scope by using the parameter SearchBase to select computers from specific OU. The following powershell script select all computers from the Organization Unit ‘TestOU’ and export it to CSV file.

Get-ADComputer -Filter * -SearchBase "OU=TestOU,DC=TestDomain,DC=com"` -Property Name,DNSHostName,Description | ` Select -Property Name,DNSHostName,Description | ` Export-CSV "C:\TestOUComputers.csv" -NoTypeInformation -Encoding UTF8

Get description for list of computers

The below powershell script gets description for list of AD computers. First create the text file computers.txt which includes one computer name in each line. You will get the name and description in the csv file ADComputers.csv.

Get-Content C:computers.txt | Get-ADComputer -Property Name,Description |` Select -Property Name,Description |` Export-CSV C:ADComputers.csv -NoTypeInformation -Encoding UTF8

Share this:

  • Facebook
  • X

Related Posts

  • Get all computers from OU in AD using PowerShell
  • Get all users in AD group using Powershell
  • PowerShell: How to Import Active Directory module
  • Get AD User Home Directory using PowerShell
  • Find AD Domain Controllers using Powershell
Advertisement

Leave a Comment Cancel reply

Comment

Name Email Website

Save my name, email, and website in this browser for the next time I comment.

Δ

Categories

  • Powershell
  • Microsoft 365
  • Azure AD
  • SharePoint Online
  • Exchange Online
  • Microsoft Teams
  • Office 365 Groups
  • Active Directory
  • Microsoft Graph
  • PnP-PowerShell
  • CSOM

Recent Posts

  • Get Azure AD (Entra ID) App-Only Access Token with PowerShell
  • Working with REST API in PowerShell using Invoke-RestMethod
  • M365 User SignIn Activity – Neither tenant is B2C or tenant doesn’t have premium license
  • How to Join or Concatenate String and Number Using PowerShell
  • Find Location and County by IP Address with PowerShell
  • Microsoft 365
  • Azure AD
  • SharePoint Online
  • Exchange Online
  • Microsoft Teams
  • Microsoft 365 Groups
  • OneDrive for Business
  • Azure AD Authentication
  • Active Directory
  • Exchange Server
  • PowerShell
  • PnP PowerShell
  • Microsoft Graph
  • CSOM
  • VBScript

Follow us

  • Facebook
  • Twitter
DMCA.com Protection Status

Tag » Add Computer Description To Active Directory Powershell