<!DOCTYPE html> <html> <head> </head> <body> <p>Changing the description of a PC can be done via script directly from a Domain Controller. <br />Below is the script to run: <br /><br /></p> <p><strong><em># Define the variables</em></strong><br /><strong><em>$DomainController = *INSERT DOMAIN CONTROLLER HERE* </em></strong><br /><strong><em>$PCName = "PC NAME" </em></strong><br /><strong><em>$Description = "DESCRIPTION"</em></strong></p> <p><strong><em># Connect to Active Directory</em></strong><br /><strong><em>Import-Module ActiveDirectory</em></strong></p> <p><strong><em># Check if the PC exists in Active Directory</em></strong><br /><strong><em>$PC = Get-ADComputer -Filter {Name -eq $PCName} -Server $DomainController</em></strong></p> <p><strong><em>if ($PC -eq $null) {</em></strong><br /><strong><em>Write-Host "The PC '$PCName' was not found in Active Directory."</em></strong><br /><strong><em>} else {</em></strong><br /><strong><em># Set the computer description</em></strong><br /><strong><em>Set-ADComputer -Identity $PCName -Description $Description -Server $DomainController</em></strong><br /><strong><em>Write-Host "The description for PC '$PCName' has been set to '$Description'."</em></strong><br /><strong><em>}</em></strong></p> <p> </p> <p> </p> <p>Replace "PC NAME" and "DESCRIPTION" with the values of the PC on which you want to make the change.</p> </body> </html>
Subscribe
0 Comments
Oldest