Move machine between Groups using Powershell
This is possible with the UI, however this does not work for a Machine.
$base = Get-RedgateMonitorBaseMonitor | Where-Object { $_.Name -match '2112' }
$inst = Get-RedgateMonitorMonitoredObject -BaseMonitor $base -Type Machine -Name "devsql0001"
$group = Get-RedgateMonitorGroup -Path 'TestGroup' -BaseMonitor $base
$instance.Group = $group
$instance | Update-RedgateMonitorMonitoredObject
HandleApiError : The remote server returned an error: (405) Method Not Allowed.
At C:\ps1\RedgateMonitor\RedgateMonitor.psm1:6008 char:9
+ HandleApiError -ErrorRecord $_ -URL $Uri -Method $Method
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Write-Error], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,HandleApiError
-
tgrove commented
H Greg,
Thank you for the heads up and quick response. Much appreciated.
We have quite a large estate and sometime need to reallocate servers between DBA Groups. Using the Powershell modules we can "move" a monitoredobject when type is Cluster.
Count Type
----- ----
2 AmazonRdsHost
1 AmazonAuroraCluster
250 Cluster
224 StandaloneMachine
622 ClusterMachine
847 MachineInstance
4 ClusterInstance
3 PostgresInstance -
Greg Smulko (Redgate) commented
Hi @tgrove, that's a very fair point.
We've added support for moving groups as a byproduct of adding support for setting aliases from PowerShell, so at the moment only monitored entities that can be aliased support setting groups.
It seems like a relatively easy change though, so we'll try to get it over the line within the next couple of weeks.