CollectorManagement/Get-Collector.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
<# .SYNOPSIS Get the information of collector(s) .DESCRIPTION Get the information of collector(s) based on id or name pattern. The result can also be retrieved in pages if there are many collectors in your organization .PARAMETER Session An instance of SumoAPISession which contains API endpoint and credential .PARAMETER Id The id of collector in long .PARAMETER NamePattern A string contains a regular expression which used to search collector(s) by name .PARAMETER Offset The offset used for paging result .PARAMETER Limit The limit (e.g. page size) used for paging result .EXAMPLE Get-Collector Get all collectors in current organization .EXAMPLE Get-Collector -Id 12345 Get collector with id 12345 .EXAMPLE Get-Collector -NamePattern "IIS" Get all collector(s) which name contains "IIS" .EXAMPLE Get-Collector -Offset 100 -Limit 50 Get all collectors in current organization in page; return 50 results from begin from the 100th result .INPUTS Not accepted .OUTPUTS PSObject to present collector(s) .NOTES You can pre-load the API credential with New-SumoSession cmdlet in script or passing in with Session parameter .LINK https://github.com/SumoLogic/sumo-powershell-sdk/blob/master/docs/Get-Collector.md .LINK https://help.sumologic.com/APIs/01Collector-Management-API/ #> function Get-Collector { [CmdletBinding(DefaultParameterSetName = "ById")] param( [SumoAPISession]$Session = $sumoSession, [parameter(ParameterSetName = "ById", Position = 0)] [long]$Id, [parameter(ParameterSetName = "ByName")] [string]$NamePattern, [parameter(ParameterSetName = "ByPage", Mandatory = $true)] [int]$Offset, [parameter(ParameterSetName = "ByPage", Mandatory = $true)] [int]$Limit ) switch ($PSCmdlet.ParameterSetName) { "ById" { if (-not ($Id)) { getAllCollectors -session $Session } else { (invokeSumoRestMethod -session $Session -method Get -function "collectors/$Id").collector } } "ByName" { getAllCollectors -session $Session | Where-Object { $_.name -match [regex]$NamePattern } } "ByPage" { getCollectorsByPage -session $Session -offset $Offset -limit $Limit } } } |