Public/Get-Bugs.ps1

function Get-Bugs {
    param( 
        [string]$ChannelId,
        [string]$EntityId,
        [string]$GroupId,
        [string]$TeamId,
        [string]$Domain = "teams-stag.appvity.com",
        [string]$t, 
        [bool]$count,
        [int]$top,
        [string]$orderby,
        [string]$Title,
        [string]$Phase,
        [string]$Bucket,
        [string]$Status
    )

    $validate = ''
    if(!$Domain){
        $validate = $validate + ', Domain'
    }
    if(!$ChannelId){
        $validate = $validate + ', ChannelId'
    }
    if(!$EntityId){
        $validate = $validate + ', EntityId'
    }
    if(!$GroupId){
        $validate = $validate + ', GroupId'
    }
    if(!$TeamId){
        $validate = $validate + ', TeamId'
    }
    if($validate) {
        $validate = $validate.TrimStart(',').TrimStart() + ' is require'
        Write-Host $validate -F Red
        return
    }

    $Url = 'https://' + $Domain.TrimEnd('/') + '/api/bugs?'
    $Url = $Url + 't=' + $t
    if($count){
        $Url = $Url + '&$count=' + $count
    }
    if($top){
        $Url = $Url + '&$top=' + $top
    }
    if($orderby){
        $Url = $Url + '&$orderby=' + $orderby
    }
    if($Title){
        $Url = $Url + '&$Title=' + $Title
    }
    if($Phase){
        $Url = $Url + '&$Phase=' + $Phase
    }
    if($Bucket){
        $Url = $Url + '&$Bucket=' + $Bucket
    }
    if($Status){
        $Url = $Url + '&$Status=' + $Status
    }

    #header
    $hd = New-Object 'System.Collections.Generic.Dictionary[String,String]'
    $hd.Add("x-appvity-channelId",$ChannelId)
    $hd.Add("x-appvity-entityId",$EntityId)
    $hd.Add("x-appvity-groupId",$GroupId)
    $hd.Add("x-appvity-teamid",$TeamId)
    $hd.Add("Content-Type","application/json")

    #cookie
    $cookie = Get-GraphOauthCookie
    #Write-Host '-------------cookie------------------'
    #Write-Host $cookie

    #session
    $session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
    $ck = New-Object System.Net.Cookie 
    $ck.Name = "graphNodeCookie"
    $ck.Value = $cookie
    $ck.Path = "/"
    $ck.Domain = $Domain
    $session.Cookies.Add($ck);

    $Params = @{
        Uri = $Url
        Method = 'GET'
        Headers = $hd
    }
    $Result = Invoke-WebRequest @Params -WebSession $session
    $Content = $Result.Content | ConvertFrom-Json
    #$Content.value | Format-List
    #Write-Host $Content.value | ConvertFrom-Json

    return $Content.value
}