Hi there,
I am building a powershell script to update Assets from a CSV that will run as a scheduled task. It works fine when the attribute types in the schema are not "Object"
Basically I am building a PSCustomObject using this
function Get-MappingData ($user) {
<#
.SYNOPSIS
This will map AD attributes to Insight fields.
#>
$mappings = [PSCustomObject]@{
Imp_Name = [PSCustomObject]@{name="Name"; id=199; value=$user.Name}
Imp_Model = [PSCustomObject]@{name="Model"; id=337; value=$user.Model}
Imp_Owner = [PSCustomObject]@{name="Owner"; id=339; value=$user.Owner}
}
return $mappings
}
When when you look at the output when I am displaying the mapping data it picks up the correct information;
[2022-11-16 11:59:11] Updating IEA-721 LAP-22-APP-2344
[2022-11-16 11:59:11] ERROR setting object: {
"objectTypeId": 49,
"attributes": [
{
"objectTypeAttributeId": 199,
"objectAttributeValues": [
{
"value": "LAP-22-APP-2344"
}
]
},
{
"objectTypeAttributeId": 337,
"objectAttributeValues": [
{
"value": "MacBook Pro - 16 Space Gray"
}
]
},
{
"objectTypeAttributeId": 339,
"objectAttributeValues": [
{
"value": "Max Taylor"
}
]
}
]
}
But it fails to do anything due to Attribute 337 and 339 being Object. I am not sure what to try and put here to somehow look up the other Schema where the People and Assets are stored to get the ID information that I am going to need for these value (I assume).
I need the Owner to be an Object as it needs to be able to bind through from the People schema to display associated assets in a ticket.
The CSV will be produced automatically from an assets system and this powershell import will happen automatically also. If I dop the Attribute 337 and 339 the script works fine as Attribute 199 is just the 'Default' type so nothing to reference there and it all works fine.
So basically I am going to need to be able to look back in Insight and match the values in the CSV and pull out the key and then use that as the update.
Just not sure how to loop backwards into Assets for that part of it?
Any suggestions?
@Ste404 you may need instead of using a String Value try to insert a Key Value for the associated object (something like KEY-1234), in my case it works.
Wondering if you found a solution? I am facing a similar issue with binding the object.
Response Code: HTTP/1.1 400 Bad Request
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.