Resolve Winmail.Dat Attachment Issue for all Office 365 Customer Tenants
The issue with Winmail.dat attachments is something that comes up pretty often for Office 365 admins. Fortunately, it’s pretty simple to resolve (See our guide here to fix it for a single Office 365 tenant). Unfortunately, you’ll need to configure it on every tenant that you manage.
If you’re tired of fixing this issue for each Office 365 tenant, here’s a quick script that will resolve it across all customer Office 365 tenants in one go.
This script will connect to all Office 365 tenants using your delegated admin credentials, and run the Set-RemoteDomain cmdlet to disable TNEF on all customer tenants.
How to fix Winmail.dat issue in all delegated Office 365 tenants
- To run this script, copy and paste it into Visual Studio Code
- Save it as a PowerShell (.ps1) file
- Press F5 to run it
- Enter the credentials of an admin with delegated access to customer tenants. Note that this script does not support MFA. To ensure that you can run it with an MFA enabled account, you can whitelist your current static IP.
- Wait for it to complete
Script for resolving Office 365 Winmail.dat issue in all customer tenants
$credential = Get-Credential Connect-MsolService -Credential $credential $customers = Get-msolpartnercontract -All foreach ($customer in $customers) { $InitialDomain = Get-MsolDomain -TenantId $customer.TenantId | Where-Object {$_.IsInitial -eq $true} Write-Host "Disabling Winmail.dat for $($customer.Name)" -ForegroundColor Green $DelegatedOrgURL = "https://outlook.office365.com/powershell-liveid?DelegatedOrg=" + $InitialDomain.Name $s = New-PSSession -ConnectionUri $DelegatedOrgURL -Credential $credential -Authentication Basic -ConfigurationName Microsoft.Exchange -AllowRedirection Import-PSSession $s -CommandName Set-RemoteDomain -AllowClobber Set-RemoteDomain Default -TNEFEnabled $false Remove-PSSession $s }
Leave a Reply
Want to join the discussion?Feel free to contribute!