Need local computer description to populate in AD during logon RRS feed

  • General discussion

  • Hello, 

    I found a bunch of scripts that populate AD with model, serial, manufacture and user name among other items. however i just need the computer description on local PC to populate in AD. the scripts below populates info in AD but not what i need and unfortunately i am no scripting guru. Any assistance is greatly appricated. Script needs to work wioth both Win7 Pro & Win10 Pro

    Script 1

    Set objADSystemInfo = CreateObject("ADSystemInfo")
    Set objLDAPComp = GetObject("LDAP://" & objADSystemInfo.ComputerName)

    objLDAPComp.Description = objADSystemInfo.UserName

    Output = MyLastName,OU=Governance,OU=IT,DC=bxgcorp,DC=com

    Script 2

    sn = GetSerialNumber
    Function GetSerialNumber
            strComputer = "."
            Set objWMIService = GetObject("winmgmts:" _
                & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
            Set colBIOS = objWMIService.ExecQuery _
                ("Select * from Win32_BIOS")
            For each objBIOS in colBIOS
                    GetSerialNumber = objBIOS.SerialNumber
    End Function
    Sub UpdateDescription(strDescription)
            Set objSysInfo = CreateObject("ADSystemInfo")
            Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
            Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
            objComputer.Description = objUser.CN & " " & strDescription
    End Sub

    Output = Full user name and serial number

    • Changed type Bill_Stewart Wednesday, September 13, 2017 9:01 PM
    • Moved by Bill_Stewart Wednesday, September 13, 2017 9:02 PM This is not "scripts on demand"
    Saturday, July 22, 2017 6:21 PM

All replies

  • We would recommend PowerShell. Also, please read this first, from the top of this forum:

    This forum is for scripting questions rather than script requests

    -- Bill Stewart [Bill_Stewart]

    Saturday, July 22, 2017 6:34 PM
  • Thank you Bill for your response. let me rephrase.

    How do i get the information from the script below to populate in AD

    Get-WMIObject  Win32_OperatingSystem | Select Description

    Saturday, July 22, 2017 6:53 PM
  • There are numerous scripts in the Gallery that do what you are trying to do.


    Saturday, July 22, 2017 7:13 PM
  • The simple answer is this:

    $computer = 'WS702'
    $description = Get-WMIObject  Win32_OperatingSystem  -computer $computer| Select -expand Description
    Set-AdComputer $computer -Description $description

    Start by learning the basics of AD and WMI then do some tutorials on PowerShell.


    Saturday, July 22, 2017 7:26 PM
  • Thank you for your response. Your suggested script error'd out, below are the results 

    PS C:\Windows\system32> $computer = 'WS702'
    $description = Get-WMIObject  Win32_OperatingSystem  -computer $computer| Select -expand Description
    Set-AdComputer $computer -Description $description

    Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
    At line:2 char:29
    + $description = Get-WMIObject <<<<   Win32_OperatingSystem  -computer $computer| Select -expand Description
        + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMException
        + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

    The term 'Set-AdComputer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, v
    erify that the path is correct and try again.
    At line:3 char:15
    + Set-AdComputer <<<<  $computer -Description $description
        + CategoryInfo          : ObjectNotFound: (Set-AdComputer:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

    Saturday, July 22, 2017 7:39 PM
  • Well you will have to learn scripting, WMI and AD to continue.  We cannot help you fix your systems or teach you basic PowerShell.  Start by getting a good basic book on Windows technology. Not a user manual but a book that teaches you how Windows is designed.  If you search you will find many resources that will help you learn how to use Widows outside of the GUI.


    Saturday, July 22, 2017 7:52 PM
  • Here is a good book assuming that you first learn Windows.


    There are dozens of other books.  THis one covers basic use of PowerShell 4 and later as well as WMI and AD.

    Here is an online course on YouTube: https://www.sapien.com/books_training/Self-Paced-Training


    Saturday, July 22, 2017 7:55 PM
  • The error is this:

    The RPC server is unavailable.

    This means that the remote computer from which you are trying to retrieve the description is not available. For Get-WmiObject to work, you must be able to connect administratively to it.

    -- Bill Stewart [Bill_Stewart]

    Saturday, July 22, 2017 9:37 PM