Client Management Suite

 View Only
  • 1.  Powershell custom inventory is not working

    Posted Oct 22, 2012 09:56 AM

    Hello,

    I am trying to create a powershell custom inventory which should collect the warranty information of a dell computer from their webside and add it into the Altiris database.

     

    The script runs fine with no errors, and I have confirmed that the data is recevied from Dell's website, but when check the table in the Altiris database, then it's empty.

    This is my script:

     

    #************************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("{e2b643b1-a5e9-4383-884e-dc065e9d4b5b}")
     
    $objDataClass = $nse.AddDataBlock($objDCInstance)
     
     
    $ServiceTag = "%SERIALNUMBER%"
        $DummyGUID = New-Object GUID('11111111-1111-1111-1111-111111111111')
        $AppName = 'Jigsaw Test'
        $proxy = New-WebServiceProxy -URI 'http://xserv.dell.com/services/assetservice.asmx'
        $Data = $proxy.GetAssetInformation($DummyGUID, $AppName, $ServiceTag)
        $Entitlements = @()
       
    ####Add new row of data
    $objDataRow = $objDataClass.AddRow()
            foreach ($item in ($Data |Select-Object -ExpandProperty Entitlements))
            {
    $objDataRow.SetField(0, $DellServiceTag)
    $objDataRow.SetField(1, $item.ServiceLevelCode)
    $objDataRow.SetField(2, $item.StartDate.ToString())
    $objDataRow.SetField(3, $item.Provider)
    $objDataRow.SetField(4, $item.EndDate.ToString())
    $objDataRow.SetField(5, $item.ServiceLevelDescription)
    $objDataRow.SetField(6, $item.EntitlementType)
     
    # Echo $ServiceTag
    # Echo $item.ServiceLevelCode
    # Echo $item.StartDate.ToString()
    # Echo $item.Provider
    # Echo $item.EndDate.ToString()
    # Echo $item.ServiceLevelDescription
    # Echo $item.EntitlementType
            }
     
    #Send the data
    $nse.sendqueued()
     


  • 2.  RE: Powershell custom inventory is not working
    Best Answer

    Posted Oct 22, 2012 10:10 AM

    Ups, I found the mistake, this line is wrong:

    $objDataRow.SetField(0, $DellServiceTag)

    it should be $objDataRow.SetField(0, $ServiceTag)

    And because that was required and was a key field it didn't add the entry into the database.