The computer model information is generally displayed in the description field of the computer object in the Active Directory Users and Computers console. This includes the hardware information of the computer including its manufacturer, model, and serial number. This in turn helps the administrators to obtain information about computer hardware such as the vendor, model, and serial number with ease. WMI queries and PowerShell scripts can be used to populate the description field of the computer object. The process of populating the description field with computer model information consists of the following steps.
- Grant permission to users for updating the computer description field
- Get the computer model information using a WMI query
- Update the description field using a PowerShell script
Granting Permission to Users for Updating the Computer Description
To populate the computer description field in Active Directory automatically, a Group Policy logon script can be used. This ensures that the data is updated at the time of start-up. This in turn requires the user to be granted the necessary access permission to update the computer objects. This permission can be granted using the Active Directory Users and Computers (ADUC) MMC snap-in, by following the steps given below.
- Open Active Directory Users and Computers (ADUC).
- Select the Advanced Features option from the View menu and ensure that this option is enabled.
- Right-click on the required domain from the left pane and select the Properties option.
- On the Security tab, click on Advanced.
- Click on Add and enter Authenticated Users. Click OK.
- From the Apply to drop-down menu, select Descendant Computer Objects.
- In the Permissions section, select the Read Description and Write Description checkboxes. Click OK.
After granting the required permissions, the computer model information can be obtained using either a WMI query or a PowerShell script. This returns information about the vendor, model name, and the identifying number of the computer. The following WMI query can be used for this purpose.
Get-WMIObject Win32_ComputerSystemProduct | Select Vendor, Name, IdentifyingNumber
The output of the above query would be:
Vendor – Lenovo
Name – Ideapad 320
IdentifyingNumber – PF19xxxx
The computer model information that is obtained using the above WMI query can be used to populate the description field of the computer object using PowerShell scripts. The Active Directory for Windows PowerShell module needs to be installed for this purpose.
The name of the computer whose details are to be updated is assigned to the $computer variable using the following command.
$computer = "PC-User-001"
Similarly, an array containing the list of all computers in the required organizational unit should be created. These are the computers for which the description field will be filled in. The computer model information for all these computers can then be obtained and their description fields can be updated using the PowerShell script given as follows.
- $computers = Get-ADComputer -Filter * -searchBase "OU=Computers,DC=ABC,DC=com"
- foreach ($computer in $computers)
- {
- $vendor = (Get-WMIObject-ComputerName $computer Win32_ComputerSystemProduct).Vendor
- $name = (Get-WMIObject-ComputerName $computer Win32_ComputerSystemProduct).Name
- $identifyingNumber = (Get-WMIObject-ComputerName $computer Win32_ComputerSystemProduct).IdentifyingNumber
- $vendor
- $name
- $identifyingNumber
- Set-ADComputer $computer –Description “$vendor : $name : $identifyingNumber”
- }
After this, a Group Policy Object (GPO) can be created to apply the logon script to all the computer objects within the selected organizational unit. This Group Policy Object is then linked to all the computers within the organizational unit. Thus the description fields of the computer objects in the selected organizational unit are filled in automatically with the computer model information.