37 C
Dubai
Tuesday, May 6, 2025
Home Blog Page 30

Adding members to unified group via csv

Make sure you Connected to Exchange Online PowerShell

Connect-ExchangeOnline

To check Unified Group Members –

Get-UnifiedGroupLinks groupname -LinkType member

Add Members to Unified Group via CSV –

Import-Csv .\usersupn.csv | ForEach-Object{Add-UnifiedGroupLinks -Identity migrate -LinkType members -Links $_.upn}

CSV Sample – Double quotes is very important otherwise you many see undesirable adds.

You can always use -WhatIf if you want to verify before applying

Import-Csv .\usersupn.csv | ForEach-Object{Add-UnifiedGroupLinks -Identity migrate -LinkType members -Links $_.upn -Whatif}

 

Add Option 60 in DHCP Server for SCCM

You need option 60 in DHCP serve inorder to run sccm task sequence to do the imaging process for windows. if you don’t see the option 60 on the dhcp server you need to add them manually.

To add Option 60

From the command line on the DHCP server,


netsh

dhcp

server

add optiondef 60 PXEClient STRING 0 comment=<userDefined>

set optionvalue 60 STRING PXEClient

show optionvalue all

 

Mailboxes into Quarantine after migrating to Exchange 2019

After migrating mailboxes to exchange 2019 from exchange 2016 . Most of the mailboxes went to quarantine all of a sudden and databases went to dismount state and came back to mount state. We couldn’t bring the databases to a stable state. We realized its a bug in exchange 2019. Initially that it was a refs formatted disk was playing around we were wrong. Still I couldn’t believe this was the fix for the crazy issue.

Get-TransportConfig | fl *size*

You can check maxsendsize and maxreceivesize should not be unlimited. Set to 35 mb for example. It works seamlessly after that . Don’t ask me why. But it works like a charm.

Set-TransportConfig -MaxReceiveSize 35MB -MaxSendSize 35MB

Good to Have –

To Take out a mailbox from Quarantine –

Disable-MailboxQuarantine "Mailbox Name"

To place a mailbox in Quarantine –

Enable-MailboxQuarantine "Mailbox Name"

To check mailboxes which are in quarantine in a database

Get-Mailbox -Database "DBName" | Get-MailboxStatistics | Where {$_.IsQuarantine -eq $True}

Simulate backup in a Exchange Server to Clear Logs

Simulating backup in a Exchange Server to Clear Logs happens sometimes when the backup stops working and the disk is about to get full. This is the only easy way to clear backups without backing up the exchange server using native disk shadow. Its a way to tell exchange server to mark these logs for deletion to gain space on the disk without enabling circular logging.


diskshadow

add volume d:

begin backup

create

end backup

Error while running ‘ldifde.exe’ to import the schema file


PS F:\&amp;gt; .\Setup.EXE /Prepareschema /IAcceptExchangeServerLicenseTerms /domaincontroller:dc01.azure365pro.local

Microsoft Exchange Server 2016 Cumulative Update 17 Unattended Setup

Copying Files...
File copy complete. Setup will now collect additional information needed for installation.

Performing Microsoft Exchange Server Prerequisite Check

Prerequisite Analysis COMPLETED

Configuring Microsoft Exchange Server

Extending Active Directory schema FAILED

The following error was generated when "$error.Clear();
install-ExchangeSchema -LdapFileName ($roleInstallPath +
"Setup\Data\"+$RoleSchemaPrefix + "schema2.ldf")

" was run: "Microsoft.Exchange.Configuration.Tasks.TaskException:
There was an error while running 'ldifde.exe' to import the schema file
'C:\windows\Temp\ExchangeSetup\Setup\Data\PostExchange2003_schema2.ldf'. The error code is: 8224. More details can be
found in the error file: 'C:\Users\administrator\AppData\Local\Temp\2\ldif.err'
at
Microsoft.Exchange.Configuration.Tasks.Task.ThrowError(Exception exception, ErrorCategory errorCategory, Object target,
String helpUrl)
at Microsoft.Exchange.Management.Deployment.InstallExchangeSchema.ImportSchemaFile(String
schemaMasterServer, String schemaFilePath, String macroName, String macroValue, WriteVerboseDelegate writeVerbose)
at
Microsoft.Exchange.Management.Deployment.InstallExchangeSchema.InternalProcessRecord()
at
Microsoft.Exchange.Configuration.Tasks.Task.&amp;lt;ProcessRecord&amp;gt;b__91_1()
at
Microsoft.Exchange.Configuration.Tasks.Task.InvokeRetryableFunc(String funcName, Action func, Boolean
terminatePipelineIfFailed)".

The Exchange Server setup operation didn't complete. More details can be found in ExchangeSetup.log located in the
&amp;lt;SystemDrive&amp;gt;:\ExchangeSetupLogs folder.
PS F:\&amp;gt;

Solution –

Make sure all Domain Controllers are reachable.
Remove any orphaned domain controllers.
Try running on domain controller itself holding the schema master.

 

OAuth and Microsoft Graph on Exchange on-premises with Hybrid Modern Authentication

Hybrid Modern Authentication (HMA) for Exchange On-Premises is being there for while which has a amazing set of features to integrate your endpoint logins to terminate in Azure AD directly. Azure AD will give a clear indication on the health of your identity and a clear visibility giving you access to Azure AD workbooks with meaningful sign in data using log analytics .It is Supported from Exchange 2013 (CU19) and 2016 (CU8).Also you can use Azure AD issued tokens to authenticate your Exchange servers on-premises which improves security drastically where you are taking a step moving away from basic Authentication and getting the advantage of Oauth. Also this is a preliminary step if you wish to utilize Windows In tune and Outlook for iOS so that you gain the advantage of device based Conditional Access.

As you are aware basic auth on Exchange Online is going away for good where Its time to move away from legacy authentication methods to keep your environment secured. I was waiting for the day Exchange Web Services needs to be killed where the first step is already announced that it will no longer receive feature updates moving away to Microsoft Graph taking advantages of all Microsoft Services from a single endpoint.

Currently its not easy to enable HMA in Exchange On-Premises as Oauth is still new for On-Prem environments where there is too much usage on legacy protocols from Meeting Room Systems to Service Desk Applications and Oracle EBS using EWS and basic auth methods so its a journey you should start moving towards Oauth. We are seeing too many custom applications using Exchange Web Services to process emails which was the only way back then to access mailbox or calendar data. I still remember writing scripts to create folders in all mailboxes using EWS Managed API for Enterprise vault Managed folders.

It would be definitely one of the best initiative to improve security and taking advantage of your Azure AD investment which you are getting through Office 365 Services. Most of the enterprise environments going to remain hybrid as there is lot of legacy behind these systems.

In Short –

  • Improved Security with Azure AD Conditional Access.
  • Improved End user Experience similar single sign ON experience like Teams or any other Office 365 services.
  • Developers can leverage latest authentication mechanisms with Microsoft Graph to retrieve and process Office 365 and On-Premises data.
  • Intelligent Identity Analytics.

Turning ON Hybrid Modern Authentication without proper planning can bring down most of your users in few hours. If your applications using EWS with basic auth it works aside with modern authentication. As enabling and disabling takes effect in 60 to 120 mins in a 4 node DAG approx. IISreset and rebooting services can help to take effect instantly.

  • No Exchange 2010 in your environment.
  • Make sure OAuth for Exchange Online is enabled. (For tenants created before August 1, 2017, modern authentication is turned off)
Connect-ExchangeOnline
Get-OrganizationConfig | FL Name,OAuth*

To Enable

Set-OrganizationConfig -OAuth2ClientProfileEnabled $true

or you can check in Admin Center https://admin.microsoft.com

  • Exchange server 2013 CU19 and above, or Exchange server 2016 CU8 and above. (Highly Recommended to be on latest roll-up)
  • No SSL Offloading on Load Balancer (Most of the Environment have SSL bridging which is what we want https on external and internal servers)
  • If Exchange Servers running behind proxy make sure InternetWebProxy is populated (Removed Authentication and SSL inspection for all Microsoft URLs in Forward Proxy)
  • Office 365 Hybrid Configuration Wizard is completed.
  • Your hybrid wizard should add all required ServicePrincipalNames (All Exchange URL entries should be listed here. email.azure365pro.com/autodiscover.azure365pro.com for example)
  • Outlook Office 365 Clients work seamlessly while comparing with Office 2016 Clients. (If you have more Office 2016 Clients keep your fingers crossed and get ready for rollback)
Connect-MsolService
Get-MsolServicePrincipal -AppPrincipalId 00000002-0000-0ff1-ce00-000000000000 | select -ExpandProperty ServicePrincipalNames

  • Decommission Skype for Business Servers (if you have one follow use this link)

Lets check how to make OAuth Authentication to onprem mailboxes without enabling Modern Authentication first once we gain the confidence and we feel everything works as expected so that you make sure all critical line of business application.

There are several ways to check OAuth is functional and working seamlessly. If Oauth is Active and functional “Calendar Tab Appears in Microsoft Teams for On-Prem users.
All new meetings visible in the Teams Client from On-Premises Exchange Servers to the cloud.

Check On-Prem EWS Connectivity using below command

Test-OAuthConnectivity -Service EWS -TargetUri https://outlook.office365.com/ews/exchange.asmx -Mailbox on-premuser@localhost -Verbose | Format-List

We can also register a application in Azure AD and use OAuth and Microsoft Graph to access On-prem mailboxes.

  • FriendlyName – azure365pro-oauth-client
  • Redirect URI (optional) –
    https://localhost

Create a Client Secret and copy the value

Add Microsoft Graph Permissions –

Choose Microsoft Graph – Delegated Permissions
Mail
Mail.Send

Add Permissions

Choose Grant Admin Consent for
Once you see “Granted” We are good to send email using OAuth

Lets use Postman free version. One of the best tools to test OAuth.
https://www.postman.com/downloads/

Create New –

Create a Sample Request and Save in to my Collection called Microsoft Graph (Name it whatever you want)

OAuth in simple words. You take the token and use the token to retrieve resources whenever you time. Until the token is valid and you can refresh the token whenever required.
lets see how to create a token

Choose Endpoints to get the required URLs

Auth URL = OAuth 2.0 authorization endpoint (v2)
Access Token URL = OAuth 2.0 token endpoint (v2)
Copy Both URLS

Copy Client ID

Request Token – Once you filled all the required information

Now you have your
Token Name = Friendly Name
Grant Type = Authorization Code
Callback URL = https://localhost
Auth URL = OAuth 2.0 authorization endpoint (v2)
Access Token URL = OAuth 2.0 token endpoint (v2)
Client ID = (Get it from the Overview Tab like below)
Client Secret = (Get it from Certificates and Secrets Tab like above)
Scope = https://graph.microsoft.com/.default
State = State
Client Authentication = Send Client Credentials in body

Now once you request token it prompts for Microsoft Login so that you can authenticate with MFA.
Choose Use Token

Lets take a sample json file fill in some sample email below (Microsoft Graph reference)

{
"message": {
"subject": "Email Through OAuth Azure365Pro",
"body": {
"contentType": "Text",
"content": "OAuth is Amazing"
},
"toRecipients": [
{
"emailAddress": {
"address": "xx@localhost"
}
}
],
"ccRecipients": [
{
"emailAddress": {
"address": "xx@localhost"
}
}
]
},
"saveToSentItems": "true"
}

Choose
Body
Raw
JSON

and Send

Now you can see the email in OnPrem Mailbox. You can see the value of Microsoft Graph you can use almost take any JSON payload and use it seamlessly.

Now We are in a good shape and utilizing Microsoft graph and in the same time verified OAuth Connectivity is healthy.
Verify OAuth is there in Authentication Methods in all On-Prem Exchange virtual directories

Get-MapiVirtualDirectory | FL server,*url*,*auth* 
Get-WebServicesVirtualDirectory | FL server,*url*,*oauth*
Get-OABVirtualDirectory | FL server,*url*,*oauth*
Get-AutoDiscoverVirtualDirectory | FL server,*oauth*

Make Sure OAuth is there in all virtual directories, Its there in default installations. Unless someone played around.

Confirm EvoSts Object exist. It is created by the hybrid wizard.

Get-AuthServer | where {$_.Name -eq "EvoSts"}

Now Schedule Maintenance Period as this is the type we need your front line teams to be equipped.

To Implement –

Set-AuthServer EvoSTS -IsDefaultAuthorizationEndpoint $true
Set-OrganizationConfig -OAuth2ClientProfileEnabled $true

To Rollback all users –

Set-AuthServer EvoSTS -IsDefaultAuthorizationEndpoint $false
Set-OrganizationConfig -OAuth2ClientProfileEnabled $false

Once users starts restarting Outlook Clients it requests them to Pass MFA or whichever if your Conditional Policy.


if you see “Bearer” you have been successfully moved from MAPI over HTTP to OAuth based Connectivity mechanism.
You can quickly rollback for all if you seeing most of users having issues.
if you see very minimal clients having issues. you can rollback them with a client based registry.

Computer\HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\Identity

REG_DWORD 0

Every environment is different.Let us know how your transition went. if your not within proxy and all clients are Outlook for Office 365 with latest patches you can see good amount of success.If you all your clients are Outlook 2016 and Outlook 2013 and not well patched you cannot see much of success. All the best.

 

× How can I help you?