functions/configurations/Get-TssMdiIntegrationConfiguration.ps1

function Get-TssMdiIntegrationConfiguration {
    <#
    .SYNOPSIS
    Get the MDI integration configuration
 
    .DESCRIPTION
    Get the Microsoft Defender for Identity (MDI) integration configuration: whether it is enabled, the Azure tenant, the synchronization interval, the last synchronization times, the consent URL and the actions the caller may take.
 
    .PARAMETER TssSession
    TssSession object created by New-TssSession for authentication
 
    .EXAMPLE
    $session = New-TssSession -SecretServer https://alpha -Credential $ssCred
    Get-TssMdiIntegrationConfiguration -TssSession $session
 
    Show the MDI integration configuration
 
    .LINK
    https://thycotic-ps.github.io/thycotic.secretserver/commands/configurations/Get-TssMdiIntegrationConfiguration
 
    .LINK
    https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/configurations/Get-TssMdiIntegrationConfiguration.ps1
 
    .NOTES
    Requires TssSession object returned by New-TssSession
 
    Secret Server Cloud only: an on-premises Secret Server answers this endpoint with Access denied.
    #>

    [CmdletBinding()]
    [OutputType('Thycotic.PowerShell.Configuration.MdiIntegrationConfiguration')]
    param (
        [Parameter(Mandatory, ValueFromPipeline, Position = 0)]
        [Thycotic.PowerShell.Authentication.Session]
        $TssSession
    )
    begin {
        $tssParams = $PSBoundParameters
        $invokeParams = . $GetInvokeApiParams $TssSession
    }
    process {
        Get-TssInvocation $PSCmdlet.MyInvocation
        if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) {
            Compare-TssVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation
            $uri = $TssSession.ApiUrl, 'configuration', 'mdi-integration' -join '/'
            $invokeParams.Uri = $uri
            $invokeParams.Method = 'GET'
            Write-Verbose "Performing the operation $($invokeParams.Method) $uri"
            try {
                $apiResponse = Invoke-TssApi @invokeParams
                $restResponse = . $ProcessResponse $apiResponse
            } catch {
                Write-Warning 'Issue with Get-TssMdiIntegrationConfiguration request'
                $err = $_
                . $ErrorHandling $err
            }
            if ($restResponse) {
                [Thycotic.PowerShell.Configuration.MdiIntegrationConfiguration](. $FilterTssResponse $restResponse ([Thycotic.PowerShell.Configuration.MdiIntegrationConfiguration]))
            }
        } else {
            Write-Warning 'No valid session found'
        }
    }
}