Skip to main content

Invoke-XdrRestMethod

SYNOPSIS

Invokes a REST API call to Microsoft Defender XDR with authenticated session.

SYNTAX

Invoke-XdrRestMethod [-Uri] <String> [[-Method] <String>] [[-ContentType] <String>] [[-WebSession] <Object>]
[[-Headers] <Hashtable>] [[-Body] <Object>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Executes REST API requests to Microsoft Defender XDR endpoints using the authenticated session and headers. This is a wrapper function that ensures connection settings are updated before making the API call.

EXAMPLES

EXAMPLE 1

Invoke-XdrRestMethod -Uri "https://security.microsoft.com/apiproxy/mtp/settings/GetAdvancedFeaturesSetting"
Makes a GET request to the specified XDR API endpoint.

EXAMPLE 2

Invoke-XdrRestMethod -Uri "https://security.microsoft.com/apiproxy/mtp/..." -Method "POST"
Makes a POST request to the specified XDR API endpoint.

PARAMETERS

-Uri

The URI of the API endpoint to call.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Method

The HTTP method to use for the request. Defaults to "GET".

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: GET
Accept pipeline input: False
Accept wildcard characters: False

-ContentType

The content type of the request. Defaults to "application/json".

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: Application/json
Accept pipeline input: False
Accept wildcard characters: False

-WebSession

The web session to use for the request. Defaults to the script-scoped session variable.

Type: Object
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: $script:session
Accept pipeline input: False
Accept wildcard characters: False

-Headers

The headers to include in the request. Defaults to the script-scoped headers variable.

Type: Hashtable
Parameter Sets: (All)
Aliases:

Required: False
Position: 5
Default value: $script:headers
Accept pipeline input: False
Accept wildcard characters: False

-Body

The body of the request, if applicable.

Type: Object
Parameter Sets: (All)
Aliases:

Required: False
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

The ProgressAction parameter is a common parameter, not a cmdlet parameter. For more information, see about_CommonParameters.

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

Object

Returns the response object from the API call.

NOTES