Get-DefenderPreferenceInfo
Windows: Retrieves Windows Defender scan and update preferences
#Requires -Version 5.1
#Requires -Modules Defender
[CmdletBinding()]
Param (
[string]$ComputerName = $env:COMPUTERNAME,
[pscredential]$Credential
)
Process {
try {
$session = $null
if ($ComputerName -ne $env:COMPUTERNAME) {
$sessionParams = @{
'ComputerName' = $ComputerName
'ErrorAction' = 'Stop'
}
if ($null -ne $Credential) {
$sessionParams.Add('Credential', $Credential)
}
$session = New-CimSession @sessionParams
$prefs = Get-MpPreference -CimSession $session -ErrorAction Stop
}
else {
$prefs = Get-MpPreference -ErrorAction Stop
}
$result = [PSCustomObject]@{
ExclusionPath = $prefs.ExclusionPath
ExclusionExtension = $prefs.ExclusionExtension
ExclusionProcess = $prefs.ExclusionProcess
RealTimeScanDirection = $prefs.RealTimeScanDirection
ScanScheduleDay = $prefs.ScanScheduleDay
ScanScheduleTime = $prefs.ScanScheduleTime
MAPSReporting = $prefs.MAPSReporting
ComputerName = $ComputerName
}
Write-Output $result
}
catch {
throw
}
finally {
if ($null -ne $session) {
Remove-CimSession $session
}
}
}Specifies the name of the target computer. Defaults to the local computer.
Specifies a PSCredential object for remote connection.