Get-IPStat.ps1

Function Get-IPStat
{
    <#
    .SYNOPSIS
        Get Defender IP Statistics.
 
    .PARAMETER Token
        Authorization token.
 
    .EXAMPLE
        $IPStat = Get-IPStat -Token $Token -IPAddress 1.1.1.1
 
    .NOTES
        Author: Michal Gajda
 
    .LINK
        https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/get-ti-indicators-collection?view=o365-worldwide
    #>

    [CmdletBinding()]
    Param
    (
        [Parameter(Mandatory = $true)]
        $Token,
        [Parameter(Mandatory = $true)]
        [String]$IPAddress
    )

    Begin {}

    Process
    {
        $Headers = @{
            'Content-Type' = 'application/json'
            Accept = 'application/json'
            Authorization = "Bearer $Token"
        }

        $Uri = "https://api.securitycenter.windows.com/api/ips/$IPAddress/stats"

        $Request = @{
            Method = "GET"
            Uri = $Uri
            Headers = $Headers
            ErrorAction = "Stop"
        }

        $Response = Invoke-RestMethod @Request

        Return $Response
    }

    End {}
}