Client Management Suite

 View Only
  • 1.  Custom Inventory - List OU

    Posted Aug 27, 2020 05:04 PM

    Hello everyone....

    I'm trying to create a custom inventory to collect the OU that the server is hosted on AD. I created the data class and working on the script to get the data in.
    Here is the script that I wrote. If I run the powershell command it brings the data to me however the problem is that when i run the script via custom inventory, it says sucessfull but the data is not on the data class. 

    #************************DO NOT EDIT********************************
    $nse = new-object -comobject Altiris.AeXNSEvent
    $nse.priority = 1
    $nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
    #************************DO NOT EDIT********************************

    #Modify this varaible with the custom data class guid
    $objDCInstance = $nse.AddDataClass("{947dd43c-9672-4018-bd3e-e371a1a3a9fc}")

    $objDataClass = $nse.AddDataBlock($objDCInstance)

    $status = Get-ADComputer $env:computername | Select-Object Name, DistinguishedName


    #Add new row of data
    $objDataRow = $objDataClass.AddRow()
    $objDataRow.SetField(0, $status)

    #Send the data
    $nse.sendqueued()

    Any idea where the problem is? If I use other powershell command, like whoami or hostname...it works fine.

    It does not have to be in powershell, this can be done via other way. 



  • 2.  RE: Custom Inventory - List OU

    Posted Aug 27, 2020 05:59 PM
    I think your problem is you're trying to assign an object ($Status) of type "PSCustomObject" to the field.  If you're trying to get the DN in the field, 

    change this line:
    $status = Get-ADComputer $env:computername | Select-Object Name, DistinguishedName

    to this:
    $status = Get-ADComputer $env:computername | Select -ExpandProperty DistinguishedName


    ------------------------------
    Ben Barker
    Systems Engineer
    benjamin.barker@bmcjax.com
    ------------------------------



  • 3.  RE: Custom Inventory - List OU

    Posted Aug 27, 2020 06:52 PM
    I tried that but still not updating the data class but it was successfull.


  • 4.  RE: Custom Inventory - List OU

    Posted Aug 28, 2020 07:15 AM
    Is the maximum length of the field set to long enough to receive the DN?

    NOTICE: This message is confidential, intended for the named recipient(s) and may contain information that is (i) proprietary to the sender, and/or,(ii) privileged, confidential and/or otherwise exempt from disclosure under applicable Florida and federal law, including, but not limited to, privacy standards imposed pursuant to the federal Health Insurance Portability and Accountability Act of 1996 ("HIPAA"). Receipt by anyone other than the named recipient(s) is not a waiver of any applicable privilege. Thank you in advance for your compliance with this notice.





  • 5.  RE: Custom Inventory - List OU

    Posted Aug 28, 2020 07:48 AM
    You are trying to insert 2 properties into 1 field. Try to put the computer name in one field and the distinguished name in the other:

    $objDataRow = $objDataClass.AddRow()
    $objDataRow.SetField(0, $status.Name)
    $objDataRow.SetField(1, $status.DistinguishedName)


  • 6.  RE: Custom Inventory - List OU

    Posted Aug 28, 2020 10:23 AM

    Guys ...it worked. Thank you very much for the help!!!!!

    This is the final version of the script. 

    #************************DO NOT EDIT********************************
    $nse = new-object -comobject Altiris.AeXNSEvent
    $nse.priority = 1
    $nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"

    #************************DO NOT EDIT********************************
    $nse = new-object -comobject Altiris.AeXNSEvent
    $nse.priority = 1
    $nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
    #************************DO NOT EDIT********************************

    #Modify this varaible with the custom data class guid
    $objDCInstance = $nse.AddDataClass("{857b6c1e-c442-490a-9f2b-1da1c990e5ff}")

    $objDataClass = $nse.AddDataBlock($objDCInstance)

    $status = Get-ADComputer $env:computername | Select -ExpandProperty DistinguishedName


    #Add new row of data
    $objDataRow = $objDataClass.AddRow()
    $objDataRow.SetField(0, $status)


    #Send the data
    $nse.sendqueued()




  • 7.  RE: Custom Inventory - List OU

    Posted Sep 11, 2020 08:53 AM
    Hi Alex

    Could'nt you just use the Inv_OU_Membership table to get the AD OU information, this information is already inventoried if using the Microsoft Active Directory Import.

    If so the SQL query below would get you this information...


    SELECT
    vc.name [Server Name]
    ,ou.[Distinguished Name] OU
    FROM vcomputer vc
    JOIN  Inv_OU_Membership ou on ou._ResourceGuid = vc.Guid and ou.IsDirectMember = 1
    WHERE  vc.[OS Name] like '%server%'
    ORDER BY ou.[Distinguished Name]




  • 8.  RE: Custom Inventory - List OU

    Posted Sep 11, 2020 06:08 PM
    Hello,

    Yes, the information about the OU for any device is already in one table, so is not needed to build dataclass.

    But in our case, we have a gap of 10% of machines that for any reason are not showing this info, not showing info because the info is not captured during any inventory: full, delta or basic. 

    No reason why this information is missing. In fact we opened a case to Symantec but the issue never was solved and then Broadcom came and the case was lost during migration. Maybe I should reopen it or create a new one. 

    I will keep my eyes on this case 





  • 9.  RE: Custom Inventory - List OU

    Posted Sep 15, 2020 02:20 PM
    For the info WDRAIN1, but i'm not using Microsoft Active Directory Import....at least for now...probably I will start using it later on.