Closed synsof closed 4 years ago
Hi @synsof,
Sensor
objects do not have a httpurl
property, and their properties also do not exactly represent "parameters" that you'd then specify to the Set-ObjectProperty
cmdlet.
Rather, the Overview section on the wiki lists all of the known properties you can modify with Set-ObjectProperty
. In this case, the name of the property we want to modify is the Url
.
As such, in order to modify both the Name
and Url
of a sensor in one go we can do the following
foreach($sensor in $sensors)
{
$properties = $sensor | Get-ObjectProperty
$newName = $proeprties.Name -replace 'ccccc', 'yyyyy'
$newUrl = $properties.Url -replace 'ccccc', 'yyyyy'
Write-Host "Changing sensor $($sensor.Name) (ID: $($sensor.Id)) Name/Url from $($properties.Name)/$($properties.Url) to $newName/$newUrl"
$sensor | Set-ObjectProperty -Name $newName -Url $newUrl
}
Regards, lordmilko
What's going on?
Our organization got sold to a new company and as part of this we need to rename all of our http sensors in prtg. Playing with some powershell variables, I was able to do essentially this with the name property, with no problem.
However, when trying to do the exact same thing with the httpurl property, it doesn't work. So, when I do
Nothing returns, and when I do
All i get is 'https://'
Then finally, when I
$params.httpurl = $rename
I get this error:
Please help, I want to be able to run this in bulk instead of going into each http sensor and replacing the characters manually.
Thanks
Due Dilligance Please enter an 'x' between the brackets to indicate you have done these