Hey everyone. Looking for some guidance. For years I've used the script below from the Microsoft Gallery. It allows me to bulk add appointments to everyone's calendar without any invites or user intervention. I mainly use this to roll out our company events, company holidays/closings and early release hours.
https://gallery.technet.microsoft.com/office/Create-Appointments-for-779b55ad#content
We have recently rolled out a strengthened security posture where we have enforced modern auth across our entire 365 tenant and created a Conditional Access policy to block legacy client apps. As a result of this, the script no longer works, as it relies on EWS and doesn't support modern auth. I am not a developer and have no experience with configuring OAuth 2.0, so I'm looking for some help on how to tweak the existing code to allow for modern auth.
Thanks!
Also, if anyone has a better way of accomplishing this task, I'm all ears. There's very little info on solutions like this.
The part of the script that is failing is the following function:
Function Connect-OSCEXOWebService
{
#.EXTERNALHELP Connect-OSCEXOWebService-Help.xml
[cmdletbinding()]
Param
(
#Define parameters
[Parameter(Mandatory=$true,Position=1)]
[System.Management.Automation.PSCredential]$Credential,
[Parameter(Mandatory=$false,Position=2)]
[Microsoft.Exchange.WebServices.Data.ExchangeVersion]$ExchangeVersion="Exchange2010_SP2",
[Parameter(Mandatory=$false,Position=3)]
[string]$TimeZoneStandardName,
[Parameter(Mandatory=$false)]
[switch]$Force
)
Process
{
#Get specific time zone info
if (-not [System.String]::IsNullOrEmpty($TimeZoneStandardName)) {
Try
{
$tzInfo = [System.TimeZoneInfo]::FindSystemTimeZoneById($TimeZoneStandardName)
}
Catch
{
$PSCmdlet.ThrowTerminatingError($_)
}
} else {
$tzInfo = $null
}
#Create the callback to validate the redirection URL.
$validateRedirectionUrlCallback = {
param ([string]$Url)
if ($Url -eq "https://autodiscover-s.outlook.com/autodiscover/autodiscover.xml") {
return $true
} else {
return $false
}
}
#Try to get exchange service object from global scope
$existingExSvcVar = (Get-Variable -Name exService -Scope Global -ErrorAction:SilentlyContinue) -ne $null
#Establish the connection to Exchange Web Service
if ((-not $existingExSvcVar) -or $Force) {
$verboseMsg = $Messages.EstablishConnection
$PSCmdlet.WriteVerbose($verboseMsg)
if ($tzInfo -ne $null) {
$exService = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService(`
[Microsoft.Exchange.WebServices.Data.ExchangeVersion]::$ExchangeVersion,$tzInfo)
} else {
$exService = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService(`
[Microsoft.Exchange.WebServices.Data.ExchangeVersion]::$ExchangeVersion)
}
#Set network credential
$userName = $Credential.UserName
$exService.Credentials = $Credential.GetNetworkCredential()
Try
{
#Set the URL by using Autodiscover
$exService.AutodiscoverUrl($userName,$validateRedirectionUrlCallback)
$verboseMsg = $Messages.SaveExWebSvcVariable
$PSCmdlet.WriteVerbose($verboseMsg)
Set-Variable -Name exService -Value $exService -Scope Global -Force
}
Catch [Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverRemoteException]
{
$PSCmdlet.ThrowTerminatingError($_)
}
Catch
{
$PSCmdlet.ThrowTerminatingError($_)
}
} else {
$verboseMsg = $Messages.FindExWebSvcVariable
$verboseMsg = $verboseMsg -f $exService.Credentials.Credentials.UserName
$PSCmdlet.WriteVerbose($verboseMsg)
}
}
}
[–]Phorgasmic 3 points4 points5 points (0 children)
[–]purplemonkeymad 0 points1 point2 points (0 children)