Public/Get-Phases.ps1

function Get-Phases {
    param( 
        [string]$Url,
        [string]$ChannelId = "19:e2599066fc7f4faaada1ffa4632adf52@thread.skype",
        [string]$EntityId = "eTask.ea217f5c-2e1f-4406-671b-194321dfb776",
        [string]$GroupId = "7243322b-db76-422e-a964-ae2bef25eee0",
        [string]$TeamId = "19:ca7641c904da4fdf92820722ff6489fc@thread.skype",
        [string]$Domain = "teams-stag.appvity.com",
        [string]$SourceId,
        [string]$Cookie
    )

    if(!$Url){
        Write-Host "Url not found." -F red
        return
    }
    if(!$SourceId){
        Write-Host "SourceId not found." -F red
        return
    }
    

    #cookie
    $cookie = $Cookie
    if(!$cookie){
        $cookie = Get-GraphOauthCookie
        #Write-Host '-------------cookie------------------'
        #Write-Host $cookie
    }

    #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")

    #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);

    $ret = Get-Projects -Url $Url -Cookie $cookie
    $SourceName = $ret | Where {$_._id -eq $SourceId} | Select source

    $Url = $Url.TrimEnd('/') + '/api/tasks/getPhase/' + $SourceName.source + '/' + $SourceId

    $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
}