Closed fab37100 closed 2 years ago
Hi @fab37100,
I would imagine in order to do this you would need to use the Get-DeviceTemplate
cmdlet to retrieve the template you want to use, and then specify a collection of those as the -RawProperty
of Set-ObjectProperty
. The DeviceTemplate
object that is retrieved will have the proper "value" to use embedded inside of it, which PrtgAPI's request engine will extract when it goes to execute the API request
Hi @lordmilko,
Yes I use Get-DeviceTemplate
cmdlet to retrieve the template I want to add at the device, but when I give the property Name
or Value
into Set-ObjectProperty -RawProperty devicetemplate_
, it doesn't work and no error has back.
That is different exemple I've used :
$a = get-device -id XXXXXX
$b = Get-DeviceTemplate | ?{$_.name -eq "Template Test.odt"}
$a | Set-ObjectProperty -RawProperty devicetemplate_ -RawValue $b
$a | Set-ObjectProperty -RawProperty devicetemplate_ -RawValue $b.value
$a | Set-ObjectProperty -RawProperty devicetemplate_ -RawValue $b.name
Last month, I was on different subject, sorry for the delay.
I had the same problem with groups. Try this:
get-device -id 12937 | Get-ObjectProperty -RawProperty devicetemplate
NSD-Switch.odt
$template = Get-DeviceTemplate "Generic Device (SNMP Enabled)"
get-device -id 12937 | set-ObjectProperty -Rawparameters @{ devicetemplate_=1 devicetemplate__check=$template} -force -verbose
get-device -id 12937 | Get-ObjectProperty -RawProperty devicetemplate
Device Generic SNMP.odt
Hi @kg7ski,
I used your feedback and it works very well, Thanks ! Now I cannot get all of templates of a device but it's another problem.
Thanks again !
What's going on?
Hi
I was tried to add template on existing device with
Get-Device -Id XXXX | Set-ObjectProperty -RawProperty "devicetemplate_" -RawValue 'Template XXXX'
but it seems wouldn't work and I don't know if I use this cmdlet correctly.I've tested the API PRTG and it's the same, I don't know if it's possible.
Due Dilligance