Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexverboon/7104e6fa24da8449c620398847e92e12 to your computer and use it in GitHub Desktop.
Save alexverboon/7104e6fa24da8449c620398847e92e12 to your computer and use it in GitHub Desktop.
Verify-MSCoreUTransportWhitelists
function Verify-MSCoreUTransportWhitelists
{
<#
.Synopsis
Verify-MSCoreUTransportWhitelists
.DESCRIPTION
The Verify-MSCoreUTransportWhitelists cmdlet lists whitelisted domains if present
Secure Score Reference: Do not use transport white lists
#>
[CmdletBinding()]
Param
(
[System.Management.Automation.PSCredential]$userCredential
)
Begin
{
Try{
#This gets us connected to an Exchange remote powershell service
$ExoSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $userCredential -Authentication Basic -AllowRedirection
Import-PSSession $ExoSession
}
Catch{
write-error "Error loading exchange online module"
Remove-PSSession $ExoSession
exit
}
}
Process
{
$whitelisttransportrules = Get-TransportRule | Where-Object {$_.Conditions -like "Microsoft.Exchange.MessagingPolicies.Rules.Tasks.SenderDomainIsPredicate" -and $_.Actions -like "Microsoft.Exchange.MessagingPolicies.Rules.Tasks.StopRuleProcessingAction"}
$result = @()
ForEach ($rule in $whitelisttransportrules)
{
$object = [PSCUSTOMOBJECT] @{
Name = $rule.Name
State = $rule.State
Description = $rule.Description
SenderDomainList = $rule.SenderDomainIs
StopRuleProcessing = $rule.StopRuleProcessing
Conditions = $rule.Conditions
Actions = $rule.Actions
}
$result = $result + $object
}
$output = [pscustomobject]@{
SecureScoreReference = "Do not use transport white lists"
RuleCount = $result.Count
Data = $result
}
}
End
{
Remove-PSSession $ExoSession
$output
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment