Functions/Get-DiscoveredIPs.ps1

<#
.SYNOPSIS
Retrieves the discovered IPs for a given stream, app, and time frame.
 
.DESCRIPTION
This function retrieves the discovered IPs for a given stream, app, and time frame by making a call to the Microsoft Graph API.
 
.PARAMETER streamID
The ID of the stream to retrieve discovered IPs for.
 
.PARAMETER appID
The ID of the app to retrieve discovered IPs for.
 
.PARAMETER timeframe
The time frame to retrieve discovered IPs for. Must be one of the following: "LastHour", "Last24Hours", "Last7Days", "Last30Days".
 
.EXAMPLE
PS C:\> Get-DiscoveredIPs -streamID "1234" -appID "5678" -timeframe "Last24Hours"
Returns the discovered IPs for the app with ID "5678" in the stream with ID "1234" for the last 24 hours.
 
.NOTES
This function requires the Invoke-GraphAPI function to be available in the current session.
#>

function Get-DiscoveredIPs {
    param (
        [Parameter(Mandatory = $true)]
        [string]$streamID,
        [Parameter(Mandatory = $true)]
        [string]$appID,
        [Parameter(Mandatory = $true)]
        [stream_time_frame]$timeframe
    )

    Begin {
        $streamTimeFrameObject = [StreamTimeFrame]::new()
        $streamTimeFrame = $streamTimeFrameObject.$timeframe
        $ErrorActionPreference = 'Stop'
        $resourceGraph = "https://graph.microsoft.com"
        $discoveredIPsEndpoint = "$resourceGraph/beta/security/dataDiscovery/cloudAppDiscovery/uploadedStreams/$streamID/$streamTimeFrame/$appID/ipAddresses"
    }
    Process {                  
                    $response = Invoke-GraphAPI -Uri $discoveredIPsEndpoint -Method Get
                    return $response.value   
    }
}