Functions/Get-DiscoveredUsers.ps1
|
<#
.SYNOPSIS Retrieves the list of discovered users for a given cloud app within a specified time frame. .DESCRIPTION The Get-DiscoveredUsers function retrieves the list of discovered users for a given cloud app within a specified time frame. The function requires the stream ID, app ID, and time frame as parameters. .PARAMETER streamID The ID of the stream that contains the cloud app data. .PARAMETER appID The ID of the cloud app. .PARAMETER timeframe The time frame for which to retrieve the discovered users. Valid values are "Last24Hours", "Last7Days", and "Last30Days". .EXAMPLE Get-DiscoveredUsers -streamID "12345" -appID "67890" -timeframe "Last7Days" This example retrieves the list of discovered users for the cloud app with ID "67890" within the last 7 days of data in the stream with ID "12345". .NOTES This function requires the Invoke-GraphAPI function to be available in the current PowerShell session. .LINK Invoke-GraphAPI #> function Get-DiscoveredUsers { 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" $discoveredUsersEndpoint = "$resourceGraph/beta/security/dataDiscovery/cloudAppDiscovery/uploadedStreams/$streamID/$streamTimeFrame/$appID/users" } Process { $response = Invoke-GraphAPI -Uri $discoveredUsersEndpoint -Method Get return $response.value } } |