osu-itis / Azure-AppService-GenerateTeams

Code to generate teams using Graph APIs. Created for use with TDx ticket forms.
1 stars 0 forks source link

Connecting to exchange Online with certificates instead of basic authentication #11

Open carrk-osu opened 3 years ago

carrk-osu commented 3 years ago

Using a certificate thumbprint with a certificate already imported within Azure

# Set the needed settings to connect to EOL with a service account
$EOLSettings = @{
    CertificateThumbPrint = $env:CertificateThumbprint
    AppID = $env:ClientID
    Organization = "OregonStateUniversity.onmicrosoft.com"
    ShowBanner = $false
}

# Use "Splatting" to use the settings as the input for the command to connect to EOL
Connect-ExchangeOnline @EOLSettings

Using a certificate and the plaintext password to connect

$EOLSettings = @{
    # Set the needed settings to connect to EOL with a service account
    CertificateFilePath = ".\EXAMPLE.pfx"
    CertificatePassword = (ConvertTo-SecureString -String $env:CertificatePassword -AsPlainText -Force)
    AppID = $env:ClientID
    Organization = "OregonStateUniversity.onmicrosoft.com"
    ShowBanner = $false
}

# Use "Splatting" to use the settings as the input for the command to connect to EOL
Connect-ExchangeOnline @EOLSettings
carrk-osu commented 3 years ago