Invoke-MtGraphSecurityQuery
SYNOPSIS
Section titled “SYNOPSIS”Execute KQL query in Microsoft 365 Defender Advanced Hunting by using Graph API Security endpoint to get results programmatically.
SYNTAX
Section titled “SYNTAX”Invoke-MtGraphSecurityQuery [-Query] <String> [-Timespan <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]DESCRIPTION
Section titled “DESCRIPTION”This cmdlet allows you to execute KQL queries against the Microsoft 365 Defender Advanced Hunting API. It simplifies the process of querying and retrieving data from the Microsoft Defender XDR for integration of Maester checks.
EXAMPLES
Section titled “EXAMPLES”EXAMPLE 1
Section titled “EXAMPLE 1”Invoke-MtGraphSecurityQuery -Query "IdentityInfo | where isnotempty(PrivilegedEntraPimRoles)" -Timespan "P14D"Get identities with eligible Entra roles of the last 14 days
Section titled “Get identities with eligible Entra roles of the last 14 days”PARAMETERS
Section titled “PARAMETERS”-Query
Section titled “-Query”Valid KQL query
Type: StringParameter Sets: (All)Aliases:
Required: TruePosition: 1Default value: NoneAccept pipeline input: True (ByValue)Accept wildcard characters: False-Timespan
Section titled “-Timespan”Lookback/timespan for KQL query in ISO 8601 duration, e.g. P14D, PT6H, P2DT3H
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: P14DAccept pipeline input: FalseAccept wildcard characters: False-ProgressAction
Section titled “-ProgressAction”Determines how PowerShell responds to progress updates generated by a script, cmdlet, or provider, such as the progress bars generated by Write-Progress.
Type: ActionPreferenceParameter Sets: (All)Aliases: proga
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: FalseCommonParameters
Section titled “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
Section titled “INPUTS”OUTPUTS
Section titled “OUTPUTS”RELATED LINKS
Section titled “RELATED LINKS”https://maester.dev/docs/commands/Invoke-MtGraphSecurityQuery