In case you are using Microsoft Defender you are familiar with the security.microsoft.com portal. You also probably know that Microsoft also offers API for this security solution.
Today I will show you some of my PowerShell commands (M365DefenderStuff module) with a focus on the 'Microsoft Defender Vulnerability Management' part.
The main benefit of using my module instead of direct API calls is built-in support for pagination, throttling, time-outs, and other nasty things ๐.
Prerequisites
Before we begin
Install M365DefenderStuff module
To be able to use my PowerShell commands, you must first install the M365DefenderStuff module from the PowerShell Gallery.
Install-Module M365DefenderStuff
๐ก
TIP: to get all available commands run the following command in your PowerShell console: Get-Command -module M365DefenderStuff
Control your M365 Defender via PowerShell
๐ก
TIP: to be able to use specific API, you need to have correct permissions. What permissions are needed is stated in the NOTES section of each function (Get-Help <functionname> -Full).
Authenticate
Import-Module Az.Accounts
Connect-AzAccount
Get all/selected machine
Get-M365DefenderMachine
Get-M365DefenderMachine -machineId 'fff5e5e26cb0848d66bbb0bc83de6bceb4a1b2e1'
Get the machine owner (the user who logs in)
Get-M365DefenderMachineUser -machineId 'fff5e5e26cb0848d66bbb0bc83de6bceb4a1b2e1'
Get detected software
Get-M365DefenderSoftware
Get-M365DefenderSoftware -softwareId 'adobe-_-creative_cloud'
Get detected vulnerabilities
Get-M365DefenderVulnerability
Get-M365DefenderVulnerability -vulnerabilityId 'CVE-2022-47926'
Generate vulnerability report
Get-M365DefenderVulnerabilityReport -groupBy machine -skipOSVuln -severity Critical
Invoke KQL query
Invoke-M365DefenderAdvancedQuery -query "DeviceInfo | join kind = fullouter DeviceTvmSoftwareEvidenceBeta on DeviceId"
Get software evidence
Invoke-M365DefenderSoftwareEvidenceQuery
Invoke-M365DefenderSoftwareEvidenceQuery -appName JRE
Get defender recommendations
Get-M365DefenderRecommendation
Get-M365DefenderRecommendation -productName 'putty'
Get-M365DefenderRecommendation -machineId '43a802402664e76a021c8dda2e2aa7db6a09a5f1'
Get all vulnerabilities per machine and software
Get-M365DefenderMachineVulnerability
That is all for now, but more functions will be added in the future to the M365DefenderStuff module don't worry ๐