commit d3d964380f901966fa5c98ec4afaba4c0d751b9a Author: aaron Date: Mon Dec 18 18:18:35 2023 +0000 Upload files to "/" diff --git a/Add-DMARCTransportRule.ps1 b/Add-DMARCTransportRule.ps1 new file mode 100644 index 0000000..41d9704 --- /dev/null +++ b/Add-DMARCTransportRule.ps1 @@ -0,0 +1,27 @@ +$LogonEmail = Read-Host "Enter Logon Email" + +Connect-ExchangeOnline -UserPrincipalName $LogonEmail + +#Internal Transport rule +$InternalRule = @{ + Name = 'DMARC Reject - Internal' + HeaderContainsMessageHeader = 'Authentication-Results' + HeaderContainsWords = 'dmarc=fail action=oreject' + RejectMessageReasonText = 'Unauthenticated email is not accepted due to the domain’’s DMARC policy' + RejectMessageEnhancedStatusCode = '5.7.1' +} + +New-TransportRule @InternalRule -Mode Enforce -FromScope InOrganization + +#External +$ExternalRule = @{ + Name = 'DMARC SCL - External' + HeaderContainsMessageHeader = 'Authentication-Results' + HeaderContainsWords = 'dmarc=fail action=oreject' + SetSCL = 5 +} +New-TransportRule @ExternalRule -Mode Enforce -FromScope NotInOrganization + +Get-TransportRule + +Disconnect-ExchangeOnline -Confirm:$false diff --git a/DKIM.ps1 b/DKIM.ps1 new file mode 100644 index 0000000..ab177c6 --- /dev/null +++ b/DKIM.ps1 @@ -0,0 +1,34 @@ +$LogonEmail = Read-Host "Enter Logon Email" + +Connect-ExchangeOnline -UserPrincipalName $LogonEmail + + +$again = $true + +while ($again) +{ + $Option = Read-Host " + Enter 'g' to see current config, + Enter 'c' to create new config, + Enter 'e' to enable DKIM + Enter 'q' to exit" + + if ($Option -eq "g") + {Get-DKIMSigningConfig} + elseif ($Option -eq "c") + { + $Domain = Read-Host "Enter Domain" + New-DKIMSigningConfig -Domain $Domain -Enabled $true + Get-DKIMSigningConfig + } + elseif ($Option -eq "e") + { + $Domain = Read-Host "Enter Domain" + Set-DKIMSigningConfig -Identity $Domain -Enabled $true + Get-DKIMSigningConfig + } + elseif ($Option -eq "q"){$again = $false} + else{Write-Host "Invalid Option, Try again"} +} + +Disconnect-ExchangeOnline -Confirm:$false \ No newline at end of file diff --git a/Disable-DMARCTransportRules.ps1 b/Disable-DMARCTransportRules.ps1 new file mode 100644 index 0000000..3b675e7 --- /dev/null +++ b/Disable-DMARCTransportRules.ps1 @@ -0,0 +1,9 @@ +$LogonEmail = Read-Host "Enter Logon Email" + +Connect-ExchangeOnline -UserPrincipalName $LogonEmail + +Disable-TransportRule -Identity "*DMARC*" + +Get-TransportRule + +Disconnect-ExchangeOnline -Confirm:$false diff --git a/Disable-DelayHold.ps1 b/Disable-DelayHold.ps1 new file mode 100644 index 0000000..5891717 --- /dev/null +++ b/Disable-DelayHold.ps1 @@ -0,0 +1,5 @@ +Connect-ExchangeOnline + +$Mailboxes = Get-Mailbox + +ForEach ($User in $Mailboxes){set-Mailbox $User.UserPrincipalName -RemoveDelayHoldApplied} \ No newline at end of file diff --git a/Get-GroupReport.ps1 b/Get-GroupReport.ps1 new file mode 100644 index 0000000..77e02c3 --- /dev/null +++ b/Get-GroupReport.ps1 @@ -0,0 +1,74 @@ +$LogonEmail = Read-Host "Enter Logon Email" +Connect-ExchangeOnline -UserPrincipalName $LogonEmail +Connect-MgGraph -Scopes "Directory.Read.All" + +class Group { + [string]$Name + [string]$DisplayName + [string]$Type + [Member[]]$Members + [string]$UserPrincipalName + [string]$MemberDisplayName + [string]$Mail +} + +class Member { + [string]$UserPrincipalName + [string]$MemberDisplayName + [string]$Mail +} + +$gs = Get-Group | Select-Object * +$Groups = +ForEach ($g in $gs){ + $Group = [Group]::new() + $Group.Name = $g.Name + $Group.DisplayName = $g.DisplayName + $Group.Type = $g.GroupType + + $ms = $g.Members + $Members = + ForEach ($m in $ms){ + $User = Get-Mailbox -Identity $m | Select-Object * + if ($User.Length -eq 1){ + $Member = [Member]::new() + $Member.UserPrincipalName = $User.UserPrincipalName + $Member.MemberDisplayName = $User.DisplayName + $Member.Mail = $User.WindowsEmailAddress + + $Member + } + else { + ForEach ($u in $User){ + $grs = Get-MgUserMemberOf -UserId $u.UserPrincipalName | Select-Object * + ForEach ($gr in $grs){ + if ($gr.AdditionalProperties.displayName -eq $g.DisplayName){ + $Member = [Member]::new() + $Member.UserPrincipalName = $u.UserPrincipalName + $Member.MemberDisplayName = $u.DisplayName + $Member.Mail = $u.WindowsEmailAddress + + $Member + } + } + } + } + } + + $Group.Members = $Members + $Group +} + +$Groups2 = +ForEach ($Group in $Groups){ + $Group + $Group2 = + ForEach ($member in $Group.Members){$member} + $Group2 = $Group2 | Sort-Object -Property UserPrincipalName -Unique + $Group2 +} + +$Groups2 | ConvertTo-Csv | Out-File ".\GroupReport.csv" + +Disconnect-MgGraph +Disconnect-ExchangeOnline