Closed athornfam2 closed 2 years ago
Key Fields aren't custom fields - Key Fields are the weird way Halo lets you see selected additional information on the asset summary screen. See here three custom fields set as Key Field 1, 2 and 3.
The end result of this design by Halo is that you cannot POST to Key Fields - they aren't writeable.
To update Custom Fields you need to post with the custom field contents in the customfields
property. Which is an array of objects containing the custom field attributes.
Any configured Key Fields will populate themselves when the relevant fields
or customfields
are populated.
@homotechsual Thanks for that explanation. Being that this module does not have examples in the get-help yet. How would I pass this array?
Got an example of the field you're trying to set @athornfam2 ?
New-HaloAsset -Asset @{ inventory_number = "$($Device.device_name)"; status_id = "1"; client_id = "12"; client_name = "Company LLC"; site_id = "18"; assettype_name = "Workstation"; {customfields @{serial_number = "$($Device.serial_number)"; os_version = "$($Device.os_version)"; model = "$($Device.model)"} } }
The fields I'm trying to parse from our RMM/MDM solution are below
Model Serial OS Version End User Agent Removed Disc Size Processor Ram Memory
They are being parsed from a json export which does work excluding the passing of custom fields.
So first things first is this requires a little prep to get the field IDs - Get-HaloField
will give you the field IDs - these should be fairly static.
Here's the simple example setting the processor (which has the field ID 122 for our test instance):
New-HaloAsset -Asset @{ inventory_number = "PSModuleTest01"; status_id = "1"; client_id = "2"; client_name = "Terry's Chocolates"; site_id = "2"; assettype_name = "Workstation"; fields = @(@{ id = 122; value = "AMD Ryzen Test"})}
You'll have to identify which of the fields you want to set are core field and which are custom fields.
Thank you so much @homotechsual and the work you do.
Reopen if you get stuck again - still working on better documentation throughout :-)
Maybe I closed it too soon. How would I go about setting multiple custom fields?
New-HaloAsset -Asset @{ inventory_number = "PSModuleTest01"; status_id = "1"; client_id = "2"; client_name = "Terry's Chocolates"; site_id = "2"; assettype_name = "Workstation"; fields = @(@{ id = 122; value = "AMD Ryzen Test"}, @{ ...
@{... ...}
would be the second custom field object. If you're setting a single field you have re-post the full array of custom fields. So if you're editing an existing object you should pull in the custom fields - change or add the new ones and then re-post the entire thing. Otherwise Halo will just empty the array and only set the single field.
For example to set both model and processor.
Set-HaloAsset -Asset @{ id = "11"; inventory_number = "PSModuleTest01"; status_id = "1"; client_id = "2"; client_name = "Terry's Chocolates"; site_id = "2"; assettype_name ="Workstation"; fields = @(@{ id = 122; value = "AMD Ryzen Test"}, @{ id = 51; value = "Test Model"})}
Just doing:
New-HaloAsset -Asset @{ id = "11"; inventory_number = "PSModuleTest01"; status_id = "1"; client_id = "2"; client_name = "Terry's Chocolates"; site_id = "2"; assettype_name ="Workstation"; fields = @(@{ id = 51; value = "Test Model"})}
Gives you:
Even if Processor etc are already set.
Contact Details
No response
What happened?
The New-HaloAsset command shows the data in the keyfield but doesn't post to the asset in Halo. The same happens when adding other keyfields (aka custom fields)
Version
1.0.1
Which operating systems have you tested on?
What PowerShell version are you running?
7.1.3
Halo Product
Halo ISTM
Halo Version
v2.88.20
What command did you run?
What was the output of the command?