Skip to content

Commit

Permalink
Merge pull request #145 from NikCharlebois/Dev
Browse files Browse the repository at this point in the history
MAJOR REVAMP - Authentication Flow
  • Loading branch information
NikCharlebois authored Jul 12, 2019
2 parents 61cf491 + 5c20ec3 commit 1d07874
Show file tree
Hide file tree
Showing 91 changed files with 428 additions and 740 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ function Get-TargetResource

Write-Verbose -Message "Getting configuration of Accepted Domain for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$AllAcceptedDomains = Get-AcceptedDomain

$AcceptedDomain = ($AllAcceptedDomains | Where-Object -FilterScript { $_.Identity -IMatch $Identity })
Expand All @@ -46,7 +48,9 @@ function Get-TargetResource
Write-Verbose -Message "AcceptedDomain configuration for $($Identity) does not exist."

# Check to see if $Identity matches a verified domain in the O365 Tenant
Test-O365ServiceConnection -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform AzureAD

$VerifiedDomains = Get-AzureADDomain | Where-Object -FilterScript { $_.IsVerified }
$MatchingVerifiedDomain = $VerifiedDomains | Where-Object -FilterScript { $_.Name -eq $Identity }

Expand Down Expand Up @@ -134,7 +138,9 @@ function Set-TargetResource

Write-Verbose -Message "Setting configuration of Accepted Domain for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$AcceptedDomainParams = @{
DomainType = $DomainType
Identity = $Identity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ function Get-TargetResource

Write-Verbose -Message "Getting configuration of AntiPhishPolicy for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$AntiPhishPolicies = Get-AntiPhishPolicy

$AntiPhishPolicy = $AntiPhishPolicies | Where-Object -FilterScript { $_.Identity -eq $Identity }
Expand Down Expand Up @@ -280,7 +282,9 @@ function Set-TargetResource

Write-Verbose -Message "Setting configuration of AntiPhishPolicy for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$AntiPhishPolicies = Get-AntiPhishPolicy

$AntiPhishPolicy = $AntiPhishPolicies | Where-Object -FilterScript { $_.Identity -eq $Identity }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ function Get-TargetResource

Write-Verbose -Message "Getting configuration of AntiPhishRule for $Identity"

Write-Verbose -Message "Calling Connect-ExchangeOnline function:"
Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

Write-Verbose -Message "Global ExchangeOnlineSession status:"
Write-Verbose -Message "$( Get-PSSession -ErrorAction SilentlyContinue | Where-Object -FilterScript { $_.Name -eq 'ExchangeOnline' } | Out-String)"

Expand Down Expand Up @@ -181,7 +182,9 @@ function Set-TargetResource

Write-Verbose -Message "Setting configuration of AntiPhishRule for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$AntiPhishRules = Get-AntiPhishRule

$AntiPhishRule = $AntiPhishRules | Where-Object -FilterScript { $_.Identity -eq $Identity }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ function Get-TargetResource
throw "EXOAtpPolicyForO365 configurations MUST specify Identity value of 'Default'"
}

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$AtpPolicies = Get-AtpPolicyForO365

$AtpPolicyForO365 = $AtpPolicies | Where-Object -FilterScript { $_.Identity -eq $Identity }
Expand Down Expand Up @@ -140,7 +142,9 @@ function Set-TargetResource
throw "EXOAtpPolicyForO365 configurations MUST specify Identity value of 'Default'"
}

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$AtpPolicyParams = $PSBoundParameters
$AtpPolicyParams.Remove('Ensure') | Out-Null
$AtpPolicyParams.Remove('GlobalAdminAccount') | Out-Null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ function Get-TargetResource

Write-Verbose -Message "Getting configuration of CASMailboxPlan for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$CASMailboxPlans = Get-CASMailboxPlan

$CASMailboxPlan = $CASMailboxPlans | Where-Object -FilterScript { $_.Identity -eq $Identity }
Expand Down Expand Up @@ -112,7 +114,8 @@ function Set-TargetResource

Write-Verbose -Message "Setting configuration of CASMailboxPlan for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$CASMailboxPlanParams = $PSBoundParameters
$CASMailboxPlanParams.Remove('Ensure') | Out-Null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ function Get-TargetResource

Write-Verbose -Message "Getting configuration of ClientAccessRule for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline


$ClientAccessRules = Get-ClientAccessRule

Expand Down Expand Up @@ -203,7 +205,9 @@ function Set-TargetResource

Write-Verbose -Message "Setting configuration of ClientAccessRule for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline


$ClientAccessRules = Get-ClientAccessRule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ function Get-TargetResource

Write-Verbose -Message "Getting configuration of DkimSigningConfig for $Identity"

Write-Verbose -Message "Calling Connect-ExchangeOnline function:"
Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

Write-Verbose -Message "Global ExchangeOnlineSession status:"
Write-Verbose -Message "$( Get-PSSession -ErrorAction SilentlyContinue | Where-Object -FilterScript { $_.Name -eq 'ExchangeOnline' } | Out-String)"
Expand Down Expand Up @@ -138,7 +138,8 @@ function Set-TargetResource

Write-Verbose -Message "Setting configuration of DkimSigningConfig for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$DkimSigningConfigs = Get-DkimSigningConfig

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ function Get-TargetResource

Write-Verbose -Message "Setting configuration of HostedConnectionFilterPolicy for $Identity"

Write-Verbose -Message "Calling Connect-ExchangeOnline function:"
Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

Write-Verbose -Message "Global ExchangeOnlineSession status:"
Write-Verbose -Message "$( Get-PSSession -ErrorAction SilentlyContinue | Where-Object -FilterScript { $_.Name -eq 'ExchangeOnline' } | Out-String)"
Expand Down Expand Up @@ -148,7 +148,8 @@ function Set-TargetResource

Write-Verbose -Message "Setting configuration of HostedConnectionFilterPolicy for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$HostedConnectionFilterPolicys = Get-HostedConnectionFilterPolicy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ function Get-TargetResource

Write-Verbose -Message "Getting configuration of HostedContentFilterPolicy for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$HostedContentFilterPolicies = Get-HostedContentFilterPolicy

Expand Down Expand Up @@ -514,7 +515,8 @@ function Set-TargetResource

Write-Verbose -Message "Setting configuration of HostedContentFilterPolicy for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$HostedContentFilterPolicies = Get-HostedContentFilterPolicy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ function Get-TargetResource

Write-Verbose -Message "Getting configuration of HostedContentFilterRule for $Identity"

Write-Verbose -Message "Calling Connect-ExchangeOnline function:"
Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

Write-Verbose -Message "Global ExchangeOnlineSession status:"
Write-Verbose -Message "$( Get-PSSession -ErrorAction SilentlyContinue | Where-Object -FilterScript { $_.Name -eq 'ExchangeOnline' } | Out-String)"
Expand Down Expand Up @@ -182,7 +182,8 @@ function Set-TargetResource

Write-Verbose -Message "Setting configuration of HostedContentFilterRule for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

Write-Verbose -Message "Global ExchangeOnlineSession status:"
Write-Verbose -Message "$( Get-PSSession -ErrorAction SilentlyContinue | Where-Object -FilterScript { $_.Name -eq 'ExchangeOnline' } | Out-String)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ function Get-TargetResource
throw "EXOHostedOutboundSpamFilterPolicy configurations MUST specify Identity value of 'Default'"
}

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$HostedOutboundSpamFilterPolicies = Get-HostedOutboundSpamFilterPolicy

Expand Down Expand Up @@ -141,7 +142,8 @@ function Set-TargetResource
throw "EXOHostedOutboundSpamFilterPolicy configurations MUST specify Identity value of 'Default'"
}

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$HostedOutboundSpamFilterPolicyParams = $PSBoundParameters
$HostedOutboundSpamFilterPolicyParams.Remove('Ensure') | Out-Null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ function Get-TargetResource
GlobalAdminAccount = $null
}

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$OrgConfig = Get-OrganizationConfig

Expand Down Expand Up @@ -120,7 +121,8 @@ function Set-TargetResource

$OrgConfig = Get-TargetResource @PSBoundParameters

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

# CASE : MailTipsAllTipsEnabled is used

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ function Get-TargetResource
Ensure = "Absent"
}

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$mailboxSettings = Get-MailboxRegionalConfiguration -Identity $DisplayName

Expand Down Expand Up @@ -84,6 +85,8 @@ function Set-TargetResource
)

Write-Verbose -Message "Setting configuration of Office 365 Mailbox Settings for $DisplayName"
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$currentMailbox = Get-TargetResource @PSBoundParameters

Expand All @@ -101,7 +104,7 @@ function Set-TargetResource
throw "The specified Time Zone {$($TimeZone)} is not valid."
}

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount

Set-MailboxRegionalConfiguration -Identity $DisplayName `
-Language $Locale `
-TimeZone $TimeZone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function Get-TargetResource

Write-Verbose -Message "Getting configuration of SafeAttachmentPolicy for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$SafeAttachmentPolicies = Get-SafeAttachmentPolicy

Expand Down Expand Up @@ -131,7 +132,8 @@ function Set-TargetResource

Write-Verbose -Message "Setting configuration of SafeAttachmentPolicy for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$SafeAttachmentPolicyParams = $PSBoundParameters
$SafeAttachmentPolicyParams.Remove('Ensure') | Out-Null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ function Get-TargetResource

Write-Verbose -Message "Getting configuration of SafeAttachmentRule for $Identity"

Write-Verbose -Message "Calling Connect-ExchangeOnline function:"
Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

Write-Verbose -Message "Global ExchangeOnlineSession status:"
Write-Verbose -Message "$( Get-PSSession -ErrorAction SilentlyContinue | Where-Object -FilterScript { $_.Name -eq 'ExchangeOnline' } | Out-String)"
Expand Down Expand Up @@ -182,7 +182,8 @@ function Set-TargetResource

Write-Verbose -Message "Setting configuration of SafeAttachmentRule for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$SafeAttachmentRules = Get-SafeAttachmentRule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ function Get-TargetResource

Write-Verbose -Message "Getting configuration of SafeLinksPolicy for $Identity"

Write-Verbose -Message "Calling Connect-ExchangeOnline function:"
Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

Write-Verbose -Message "Global ExchangeOnlineSession status:"
Write-Verbose -Message "$( Get-PSSession -ErrorAction SilentlyContinue | Where-Object -FilterScript { $_.Name -eq 'ExchangeOnline' } | Out-String)"
Expand Down Expand Up @@ -150,7 +150,8 @@ function Set-TargetResource

Write-Verbose -Message "Setting configuration of SafeLinksPolicy for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$SafeLinksPolicies = Get-SafeLinksPolicy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ function Get-TargetResource

Write-Verbose -Message "Setting configuration of SafeLinksRule for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$SafeLinksRules = Get-SafeLinksRule
$SafeLinksRule = $SafeLinksRules | Where-Object -FilterScript { $_.Identity -eq $Identity }
Expand Down Expand Up @@ -170,7 +171,8 @@ function Set-TargetResource

Write-Verbose -Message "Setting configuration of SafeLinksRule for $Identity"

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$SafeLinksRules = Get-SafeLinksRule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ function Get-TargetResource
Ensure = "Absent"
}

Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

$mailboxes = Get-Mailbox
$mailbox = $mailboxes | Where-Object -FilterScript {
Expand Down Expand Up @@ -116,7 +117,8 @@ function Set-TargetResource
#endregion

$CurrentParameters = $PSBoundParameters
Connect-ExchangeOnline -GlobalAdminAccount $GlobalAdminAccount
Test-MSCloudLogin -O365Credential $GlobalAdminAccount `
-Platform ExchangeOnline

# CASE: Mailbox doesn't exist but should;
if ($Ensure -eq "Present" -and $currentMailbox.Ensure -eq "Absent")
Expand Down
Loading

0 comments on commit 1d07874

Please sign in to comment.