Forum Discussion
7 years ago
Your experience is interesting, because I update the displayName property of our new collectors several times a week. In the script we use to deploy collectors, I use the following code:
$BlockLogging = $true # Just used for this example, to prevent the steps from being written to the event log. $collectorProperties = @{"displayName" = "testdevice"; "hostGroupIds" = "<a valid group ID>"} Foreach ($keyValuePair in $collectorProperties.GetEnumerator()) { Try { $lmResponse = Update-LogicMonitorDeviceProperties -AccessId $lmAccessId -AccessKey $lmAccessKey -AccountName <account> -DeviceId <device ID> -PropertyNames $keyValuePair.Key -PropertyValues $keyValuePair.Value } Catch { $message = ("{0}: Unexpected error updating the property: {1} on {2}. The value should be: {3}. The specific error is: {4}." -f (Get-Date -Format s), $keyValuePair.Key, $hubLongName, $keyValuePair.Value, $lmResponse) If ($BlockLogging) {Write-Host $message -ForegroundColor Red} Else {Write-Host $message -ForegroundColor Red; Write-EventLog -LogName Application -Source $EventLogSource -EntryType Error -Message $message -EventId 5417} } }
If you put the displayName property into a hash table like I did, do you have the same problem?
I'll try to find some time to create the other cmdlet you suggested.
Related Content
- 4 months ago
- 11 months ago
- 8 months ago
- 2 years ago