locked
Powershell ADSI Computer Description RRS feed

  • Question

  • Hoping I could get some help with a script I'm putting together that I'm wanting to use with MDT. I have a large portion of MDT automated and I'm going back through and stream lining a couple of "would be nice" items.

    What I'm hoping to accomplish with the script is that it will take variables that I feed to it and set them in the AD Description field for a given PC name. I've pieced together some scripts I've found and feel I'm close to a working solution. I'm needing to use ADSI because the script needs to run within the OS and I am not able to have the AD Powershell module installed due to security constraints. I'm needing to feed the script credentials that are pulled from the MDT TS variable for user name and password due to other reasons. Hopefully I'm not too far off from a working solution.

    $Credential = Get-Credential -Credential domain\user
    $strDesc="Testing"
    $strDN = "CN=ComputerName,OU=Test_OU,DC=DCname"
      $Computer = [ADSI]"LDAP://$strDN" 
      $Computer.description = $strDesc

      New-Object -TypeName System.DirectoryServices.DirectoryEntry -ArgumentList "$Computer.description" ,$($Credential.UserName),$($Credential.GetNetworkCredential().password)


    Wednesday, February 14, 2018 8:19 PM

All replies