Exchange Online v2 Powershell Unattended for Scripting

Поділитися
Вставка
  • Опубліковано 16 вер 2024
  • Microsoft is deprecating the Exchange Online Basic Auth and that requires you to use Exchange Online Version v2 and you will have a lot of scripts currently running to fetch/modify information in office 365 exchange online.
    You can follow instructions in this video to update your script running unattended exchange online scripts.
    High Level these are the steps :
    create a self signed certificate
    New-SelfSignedCertificate -FriendlyName "Exch Unattended Script" -Subject "Exch Unattended Script" -CertStoreLocation "cert:\CurrentUser\My" -KeySpec KeyExchange
    Export Certificate
    $cert = Get-ChildItem -Path Cert:\CurrentUser\My\{put certificate thumbprint}
    Export-Certificate -Cert $cert -FilePath $home\Desktop\ExchangeOnlinev2\exchauth.cer
    Create App Registration and grant admin consent
    Grant Exchange.ManageAsApp Right under Office 365 Exchange Online
    Assign Exchange Admin Role to the newly registered App.
    Upload Certificate Public Key to recently created App in Azure.
    Run Command On Prem to find if unattended script works
    Connect-ExchangeOnline -AppId {AppID} -CertificateThumbprint {CertThumbprint} -Organization {TenantFQDN.onmicrosoft.com}
    Sample Script for task scheduler job to export script.
    $session = Connect-ExchangeOnline -CertificateThumbprint {CertThumbprint} -AppId {AppID} -ShowBanner:$false -Organization {TenantFQDN.onmicrosoft.com}
    $rcpt = Get-ExoMailbox -resultsize unlimited | select *
    $rcpt | export-csv $home\Desktop\ExchangeOnlinev2\MB_exported.csv -NTI
    Disconnect-ExchangeOnline -Confirm:$false -InformationAction Ignore -ErrorAction SilentlyContinue

КОМЕНТАРІ • 5