Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Updated Discovered Apps cmdlet to enumerate all apps. #96

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions Functions/Get-MCASDiscoveredApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@

Retrieves the first 5 app names sorted alphabetically.

.EXAMPLE
PS C:\> Get-MCASDiscoveredApp -All -StreamId $streamid | select name

name
----
1ShoppingCart
ABC News
ACTIVE
AIM
AT&T
...

Retrieves all app names

.EXAMPLE
PS C:\> Get-MCASDiscoveredApp -StreamId $streamid -Category SECURITY | select name,@{N='Total (MB)';E={"{0:N2}" -f ($_.trafficTotalBytes/1MB)}}

Expand Down Expand Up @@ -59,6 +73,11 @@ function Get-MCASDiscoveredApp {
[ValidateNotNullOrEmpty()]
[int]$ResultSetSize = 100,

# Specifies to retrieve all apps that match filters
[Parameter(ParameterSetName='List', Mandatory=$false)]
[ValidateNotNullOrEmpty()]
[Switch]$All,

# Specifies the number of records, from the beginning of the result set, to skip. Set to 0 by default.
[Parameter(ParameterSetName='List', Mandatory=$false)]
[ValidateScript({$_ -gt -1})]
Expand Down Expand Up @@ -211,20 +230,21 @@ function Get-MCASDiscoveredApp {
#endregion ----------------------------FILTERING----------------------------

try {
#$response = Invoke-MCASRestMethod -Credential $Credential -Path "/cas/api/discovery/" -Method Post -Body $body #-FilterSet $filterSet
$response = Invoke-MCASRestMethod -Credential $Credential -Path "/cas/api/v1/discovery/discovered_apps/" -Method Post -Body $body -FilterSet $filterSet
if ($All){
$body.limit = 100
do{
$rawresponse = Invoke-MCASRestMethod -Credential $Credential -Path "/api/v1/discovery/discovered_apps/" -Method Post -Body $body -FilterSet $filterSet
$response += $rawresponse.data
$body.skip += 100
} while ($response.count % 100 -eq 0)
}
else{
$rawresponse = Invoke-MCASRestMethod -Credential $Credential -Path "/api/v1/discovery/discovered_apps/" -Method Post -Body $body -FilterSet $filterSet
$response = $rawresponse.data
}
}
catch {
throw "Error calling MCAS API. The exception was: $_"
}

$response = $response.data

try {
Write-Verbose "Adding alias property to results, if appropriate"
$response = $response | Add-Member -MemberType AliasProperty -Name Identity -Value 'appId' -PassThru
}
catch {}

$response
}