Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added prompt to open browser to the new rule #33

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Exchange/MailboxStorageReport.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Connect-ExchangeOnline -UserPrincipalName [email protected]

$MailboxStorage = Get-Mailbox -ResultSize Unlimited | ForEach-Object {
$PrimaryStats = Get-MailboxStatistics $_.Identity
$ArchiveStats = if ($_.ArchiveStatus -eq "Active") { Get-MailboxStatistics -Archive $_.Identity } else { $null }
[PSCustomObject]@{
User = $_.DisplayName
PrimaryMailboxSize = $PrimaryStats.TotalItemSize.Value.ToString()
ArchiveMailboxSize = if ($ArchiveStats) { $ArchiveStats.TotalItemSize.Value.ToString() } else { "No Archive" }
PrimaryItemCount = $PrimaryStats.ItemCount
ArchiveItemCount = if ($ArchiveStats) { $ArchiveStats.ItemCount } else { "No Archive" }
}
}

$MailboxStorage | Export-Csv -Path "MailboxStorageReport.csv" -NoTypeInformation -Encoding UTF8
2 changes: 1 addition & 1 deletion Phishing Mail Warning/AddPhishingMailWarning.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $HTMLDisclaimer = '<table border=0 cellspacing=0 cellpadding=0 align="left" widt
Write-Host "Creating Transport Rule" -ForegroundColor Cyan

# Create new Transport Rule
New-TransportRule -Name "External Email Warning test" `
New-TransportRule -Name "Phishing Warning" `
-FromScope NotInOrganization `
-SentToScope InOrganization `
-SubjectOrBodyMatchesPatterns (Get-Content $PSScriptRoot\PhishingPatterns.txt) `
Expand Down
19 changes: 19 additions & 0 deletions Phishing Mail Warning/ImpersonationMailWarning.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ Function Remove-ExistingRules {
# Get all existing users
$displayNames = (Get-EXOMailbox -ResultSize unlimited -RecipientTypeDetails usermailbox).displayname

#sort the display names
$displaynames = $displayNames | Sort-Object

# Set the transport rule name
$transportRuleName = "Impersonation warning"

Expand Down Expand Up @@ -130,6 +133,22 @@ else {
Write-Host "Transport rule created" -ForegroundColor Green
}

# Get the transport rules again so we can open a browser directly to it (only link to the first rule found)
$existingTransportRule = Get-TransportRule | Where-Object {$_.Name -like $transportRuleName+"*"} | Select-Object -First 1

#build the URL
$urlPrefix = "https://admin.exchange.microsoft.com/#/transportrules/:/ruleDetails/"
$ruleURL = $urlPrefix + $existingtransportrule.Guid + "/viewinflyoutpanel"

# Open a browser to the Transport Rule
write-host "Rule URL: " -NoNewline
write-host $ruleURL -ForegroundColor Cyan
$OpenInProwser = Read-Host Open browser to URL? [Y] Yes [N] No

if ($OpenInProwser -match "[yY]") {
Start-Process $ruleURL
}

# Close Exchange Online Connection
$close = Read-Host Close Exchange Online connection? [Y] Yes [N] No

Expand Down