Public/Set-SwNodeStatusType.ps1
Function Set-SwNodeStatusType { <# .SYNOPSIS Set polling method of node status checking. .DESCRIPTION You can simply use this function to change polling method of each node and change it from ICMP to Agent or vice versa! Note: Node Id of target machine is required, you can execute "Get-Node" command to find node Id. #> [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='None')] Param ( [Parameter(Mandatory = $true)] [SolarWinds.InformationService.Contract2.InfoServiceProxy]$InfoServiceProxy, [Parameter(Mandatory = $true)] [int]$NodeId, [Parameter(Mandatory = $true)] [ValidateSet('ICMP', 'Agent')] [string]$Status ) Begin{ $id = $NodeId.ToString() $disableSetting = @{ Enabled = 'False'; } $enableSetting = @{ Enabled = 'True'; } } Process{ if($PSCmdlet.ShouldProcess( "Verbose Description !", "Set Resource " + "Caption")){ Write-Verbose -Message "Sending command to server ... " if ($Status -eq "ICMP"){ $Query = "SELECT uri from Orion.Pollers where NetObjectID = '$id' and POllerType = 'N.Status.ICMP.Native'"; $Uri = get-swisData -SwisConnection $InfoServiceProxy -Query $Query Set-SwisObject -SwisConnection $InfoServiceProxy -Uri $Uri -Properties $enableSetting #*************** $Query = "SELECT uri from Orion.Pollers where NetObjectID = '$id' and POllerType = 'N.ResponseTime.ICMP.Native'"; $Uri = get-swisData -SwisConnection $InfoServiceProxy -Query $Query Set-SwisObject -SwisConnection $InfoServiceProxy -Uri $Uri -Properties $enableSetting #*************** $Query = "SELECT uri from Orion.Pollers where NetObjectID = '$id' and POllerType = 'N.Status.Agent.Native'"; $Uri = get-swisData -SwisConnection $InfoServiceProxy -Query $Query Set-SwisObject -SwisConnection $InfoServiceProxy -Uri $Uri -Properties $disableSetting #*************** $Query = "SELECT uri from Orion.Pollers where NetObjectID = '$id' and POllerType = 'N.ResponseTime.Agent.Native'"; $Uri = get-swisData -SwisConnection $InfoServiceProxy -Query $Query Set-SwisObject -SwisConnection $InfoServiceProxy -Uri $Uri -Properties $disableSetting } else{ $Query = "SELECT uri from Orion.Pollers where NetObjectID = '$id' and POllerType = 'N.Status.ICMP.Native'"; $Uri = get-swisData -SwisConnection $InfoServiceProxy -Query $Query Set-SwisObject -SwisConnection $InfoServiceProxy -Uri $Uri -Properties $disableSetting #*************** $Query = "SELECT uri from Orion.Pollers where NetObjectID = '$id' and POllerType = 'N.ResponseTime.ICMP.Native'"; $Uri = get-swisData -SwisConnection $InfoServiceProxy -Query $Query Set-SwisObject -SwisConnection $InfoServiceProxy -Uri $Uri -Properties $disableSetting #*************** $Query = "SELECT uri from Orion.Pollers where NetObjectID = '$id' and POllerType = 'N.Status.Agent.Native'"; $Uri = get-swisData -SwisConnection $InfoServiceProxy -Query $Query Set-SwisObject -SwisConnection $InfoServiceProxy -Uri $Uri -Properties $enableSetting #*************** $Query = "SELECT uri from Orion.Pollers where NetObjectID = '$id' and POllerType = 'N.ResponseTime.Agent.Native'"; $Uri = get-swisData -SwisConnection $InfoServiceProxy -Query $Query Set-SwisObject -SwisConnection $InfoServiceProxy -Uri $Uri -Properties $enableSetting } } } End{ } } |