<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Microsoft Office 365 Archives - Wiredwolf Canada</title>
	<atom:link href="https://catastrophe.wiredwolf.com/category/microsoft-office-365/feed/" rel="self" type="application/rss+xml" />
	<link>https://catastrophe.wiredwolf.com/category/microsoft-office-365/</link>
	<description></description>
	<lastBuildDate>Sat, 27 Apr 2024 01:20:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Office 365 &#8211; Migrating Distribution Groups</title>
		<link>https://catastrophe.wiredwolf.com/office-365-migrating-distribution-groups/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 27 Apr 2024 00:54:48 +0000</pubDate>
				<category><![CDATA[Microsoft Exchange]]></category>
		<category><![CDATA[Microsoft Office 365]]></category>
		<category><![CDATA[PowerShell]]></category>
		<guid isPermaLink="false">https://catastrophe.wiredwolf.com/?p=22459</guid>

					<description><![CDATA[<p>Distribution Groups stuck in Active Directory can cause issues after an Exchange migration.   Users can no longer access the management of a Distribution Group in Outlook Synchronized Distribution Groups in Office 365 cannot be modified in Office 365 - as a synchronized object you must update in Active Directory Adding external contacts to a synchronized  [...]</p>
<p>The post <a href="https://catastrophe.wiredwolf.com/office-365-migrating-distribution-groups/">Office 365 &#8211; Migrating Distribution Groups</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Distribution Groups stuck in Active Directory can cause issues after an Exchange migration.&nbsp;&nbsp;</p>
<ul>
<li>Users can no longer access the management of a Distribution Group in Outlook</li>
<li>Synchronized Distribution Groups in Office 365 cannot be modified in Office 365 &#8211; as a synchronized object you must update in Active Directory</li>
<li>Adding external contacts to a synchronized Distribution Group becomes difficult as you cannot synchronize contacts with Azure AD Connect</li>
</ul>
<p>The solution is relatively simple &#8211; convert all Distribution Groups to Cloud objects.</p>
<p>This script was designed to do exactly that.</p>
<blockquote>
<div>
<div>&lt;#</div>
<div>#########################################################################################</div>
<div>##</div>
<div>## Name: &nbsp; &nbsp; &nbsp; &nbsp;DG_Cloud.PS1</div>
<div>##</div>
<div>## Version: &nbsp; &nbsp; 1.0</div>
<div>##</div>
<div>## Description: $ Installs required components for Exchange Online Powershell Management</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$ Creates a &#8220;Working&#8221; folder for Sea to Sky (C:\STS) for backups.</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$ Creates an &#8220;Exports&#8221; folder for the temp files needed to migrate the</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Distribution Lists.</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$ Backs up the Distribution List Names and Attributes to DG_Details_Backup.csv</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$ Backs up the Distribution List Members to DG_Members_Backup.csv</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$ Capable of running mulitple times and retaining existing backups &#8211; creates</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;new backups each time it&#8217;s run if any new groups are detected</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$ Selectively Creates a copy of each Distribution Group called Cloud_$Group</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;that are specifically Distribution Groups and not Mail-Enabled Security</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;groups.</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$ Deletes the selected Distribtuion Groups from Active Directory</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$ Initiates an Azure AD Connect to remove the AD objects from Cloud Environment</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$ Forces wait period of 5 minutes to allow Azure AD to synchronize with Exchange</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$ Completes process by renaming Cloud_$Group back to original name</div>
<div>##</div>
<div>## Usage: &nbsp; &nbsp; &nbsp; Execute script in PowerShell with elevated privileges</div>
<div>##</div>
<div>## Author: Jason Zondag</div>
<div>##</div>
<div>## Disclaimer: &nbsp;Has not been tried in every conceivable environment &#8211; always check the results</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and fall back on the backups created to recreate the Distribution Groups if</div>
<div>## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;necessary</div>
<div>##</div>
<div>#########################################################################################</div>
<div>###### ALTERNATIVE CODE FOR MFA LOGIN TO OFFICE 365 &nbsp;####################################</div>
<div>#Connect &amp; Login to ExchangeOnline (MFA)</div>
<div>$getsessions = Get-PSSession | Select-Object -Property State, Name</div>
<div>$isconnected = (@($getsessions) -like &#8216;@{State=Opened; Name=ExchangeOnlineInternalSession*&#8217;).Count -gt 0</div>
<div>If ($isconnected -ne &#8220;True&#8221;) {</div>
<div>Connect-ExchangeOnline</div>
<div>}</div>
<div>#########################################################################################</div>
<div>#&gt;</div>
<div>clear</div>
<div>Write-Host &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221; -ForegroundColor Cyan</div>
<div>Write-Host &#8220;!!!!!IMPORTANT!!!!!!&#8221; -ForeGroundColor Red</div>
<div>Write-Host &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221; -ForegroundColor Cyan</div>
<div>Write-Host &#8220;!!!!!IMPORTANT!!!!!!&#8221; -ForeGroundColor Red</div>
<div>Write-Host &#8220;YOU MUST RUN THIS SCRIPT FROM THE DOMAIN CONTROLLER THAT IS RUNNING AZURE AD CONNECT&#8221; -ForeGroundColor Red</div>
<div>sleep 5</div>
<div>Write-Host &#8220;IF YOU ARE NOT PLEASE USE CTRL + C TO ESCAPE AND RUN FROM THE APPROPRIATE DOMAIN CONTROLLER&#8221; -ForeGroundColor Red</div>
<div>Write-Host &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221; -ForegroundColor Cyan</div>
<div>Write-Host &#8220;It&#8217;s also important to note that this only affects Distribution Lists and not Mail-Enabled&#8221; -ForeGroundColor Green</div>
<div>Write-Host &#8220;Security Groups. &nbsp;Mail-Enabled Security Groups must be handled differently.&#8221; -ForeGroundColor Green</div>
<div>Write-Host &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221; -ForegroundColor Cyan</div>
<div>sleep 15</div>
<div>Pause</div>
<div>Write-Host &#8220;Connecting to Exchange Online &#8211; installing all required PowerShell Modules and initiaing a connection&#8221; -ForegroundColor Green</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div># Load PowerShell Modules</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div>Set-ExecutionPolicy RemoteSigned -Force</div>
<div>Import-Module ActiveDirectory</div>
<div>[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12</div>
<div>Install-Module -Name ExchangeOnlineManagement -Force</div>
<div>Import-Module ExchangeOnlineManagement</div>
<div>#Connect &amp; Login to ExchangeOnline (MFA)</div>
<div>$getsession = get-pssession | select-object -Property State | select -expandproperty state</div>
<div>If ($getsession -ne &#8220;Opened&#8221;) {</div>
<div>Connect-ExchangeOnline</div>
<div>}</div>
<div>Write-Host &#8220;Completed&#8221; -ForegroundColor Green</div>
<div>Write-Host &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221; -ForegroundColor Cyan</div>
<div>Write-Host</div>
<div>Write-host</div>
<div>Write-Host &#8220;______________________________________________________________________________________________&#8221; -ForegroundColor Cyan</div>
<div>Write-Host &#8220;Synchronized Distribution Groups with no ManagedBy settings will be defaulted to Organization&#8221; -ForeGroundColor Yellow</div>
<div>Write-Host &#8220;Management. This value cannot be translated.&#8221; -ForeGroundColor Yellow</div>
<div>Write-host</div>
<div>Write-Host &#8220;You must set a default account value to replace Organization Management.&#8221; -ForeGroundColor Green</div>
<div>Write-Host &#8220;The default account must be a valid licensed address for this tenant. &nbsp;IE. seatosky@domain.com &#8221; -ForeGroundColor Green</div>
<div>$ManagedByDefault = Read-host &#8220;Enter the email address of a valid licensed account for this tenant:&#8221;</div>
<div>Write-Host &#8220;______________________________________________________________________________________________&#8221; -ForegroundColor Cyan</div>
<div># Disable Azure AD Connect from initiating a sync while this process is underway</div>
<div>Set-ADSyncScheduler -SyncCycleEnabled $false</div>
<div>Write-host &#8220;Azure AD Connect Schedule Sync has been disabled temporarily.&#8221;</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div># Create Working and Export folders</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div>Write-Host &#8220;Creating a Working Directory C:\DG-Migrate and an Exports Directory within the Working Directory&#8221; -ForegroundColor Green</div>
<div># Create a working directory</div>
<div>$orginfo = Get-OrganizationConfig | select -expandproperty Name</div>
<div>$WorkingDirectory = &#8220;C:\DG-Migrate\&#8221; + $orginfo + &#8220;\&#8221;</div>
<div>$ExportDirectory = $WorkingDirectory + &#8220;ExportedAddresses\&#8221;</div>
<div>If(!(Test-Path -Path $WorkingDirectory )){</div>
<div># if WorkingDirectory doesn&#8217;t exist neither does ExportDirectory &#8211; create them both</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write-Host &#8221; &nbsp;Creating Directory: $WorkingDirectory&#8221;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; New-Item -ItemType directory -Path $WorkingDirectory | Out-Null</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write-Host &#8221; &nbsp;Creating Directory: $ExportDirectory&#8221;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; New-Item -ItemType directory -Path $ExportDirectory | Out-Null</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; } else {</div>
<div># WorkingDirectory may exist but that doesn&#8217;t mean ExportDirectory does &#8211; create if it doesn&#8217;t exist</div>
<div>If(!(Test-Path -Path $ExportDirectory )){</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write-Host &#8221; &nbsp;Creating Directory: $ExportDirectory&#8221;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; New-Item -ItemType directory -Path $ExportDirectory | Out-Null</div>
<div>}</div>
<div>}</div>
<div>Write-Host &#8220;Completed&#8221; -ForegroundColor Green</div>
<div>Write-Host &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221; -ForegroundColor Cyan</div>
<div>Write-Host &#8220;Creating a backup of all AD Synchronized Distribution Lists and placing into the Working Directory&#8221; -ForegroundColor Green</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div># Export all the Distribution Group Information to a separate file</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div>$check = (get-distributiongroup | Where {($_.IsDirSynced -eq $true) -AND ($_.RecipientType -eq &#8220;MailUniversalDistributionGroup&#8221;)})</div>
<div>if ((($check | Measure-Object).count) -ne 0) {</div>
<div># Not 0 so we found some Distribution Groups to migrate</div>
<div># We don&#8217;t want to overwrite an existing backup set &#8211; rename any existing files with a time stamp</div>
<div>&nbsp; &nbsp; if (Test-Path ($WorkingDirectory + &#8220;DG_Details_Backup.csv&#8221;)) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $filename = ($WorkingDirectory + &#8220;DG_Details_Backup.csv&#8221;)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $fileObj = get-item $filename</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $DateStamp = get-date -uformat &#8220;%Y-%m-%d@%H-%M-%S&#8221;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $extOnly = $fileObj.extension</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; if ($extOnly.length -eq 0) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $nameOnly = $fileObj.Name</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rename-item &#8220;$fileObj&#8221; &#8220;$nameOnly-$DateStamp&#8221;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; else {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $nameOnly = $fileObj.Name.Replace( $fileObj.Extension,&#8221;)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rename-item &#8220;$fileName&#8221; &#8220;$nameOnly-$DateStamp$extOnly&#8221;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; }</div>
<div>$check | select `</div>
<div>&nbsp; &nbsp; GroupType, `</div>
<div>&nbsp; &nbsp; SamAccountName, `</div>
<div>&nbsp; &nbsp; IsDirSynced, `</div>
<div>&nbsp; &nbsp; @{label=&#8221;ManagedBy&#8221;;expression={</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; ($_.managedby `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; | % { get-mailbox -identity $_ | select-object -ExpandProperty PrimarySMTPAddress } `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; | Where-Object {$_ -like &#8220;*@*&#8221;}) -join &#8216;;&#8217;}</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }, `</div>
<div>&nbsp; &nbsp; MemberJoinRestriction, `</div>
<div>&nbsp; &nbsp; MemberDepartRestriction, `</div>
<div>&nbsp; &nbsp; ReportToOriginatorEnabled, `</div>
<div>&nbsp; &nbsp; Description, `</div>
<div>&nbsp; &nbsp; AddressListMembership, `</div>
<div>&nbsp; &nbsp; Alias, `</div>
<div>&nbsp; &nbsp; DisplayName, `</div>
<div>&nbsp; &nbsp; PrimarySMTPAddress, `</div>
<div>&nbsp; &nbsp; @{label=&#8221;EmailAddressess&#8221;;expression={</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; ($_.EmailAddresses | Where-Object {$_ -like &#8220;*smtp:*&#8221; }) -join &#8216;;&#8217;}</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; },`</div>
<div>&nbsp; &nbsp; ExternalDirectoryObjectId, `</div>
<div>&nbsp; &nbsp; HiddenFromAddressListsEnabled, `</div>
<div>&nbsp; &nbsp; LegacyExchangeDN, `</div>
<div>&nbsp; &nbsp; MaxSendSize, `</div>
<div>&nbsp; &nbsp; MaxReceiveSize, `</div>
<div>&nbsp; &nbsp; ModeratedBy, `</div>
<div>&nbsp; &nbsp; ModerationEnabled, `</div>
<div>&nbsp; &nbsp; PoliciesIncluded, `</div>
<div>&nbsp; &nbsp; PoliciesExcluded, `</div>
<div>&nbsp; &nbsp; EmailAddressPolicyEnabled, `</div>
<div>&nbsp; &nbsp; RecipientType, `</div>
<div>&nbsp; &nbsp; RecipientTypeDetials, `</div>
<div>&nbsp; &nbsp; RequireSenderAuthenticationEnabled, `</div>
<div>&nbsp; &nbsp; WindowsEmailAddress, `</div>
<div>&nbsp; &nbsp; Identity, `</div>
<div>&nbsp; &nbsp; Id, `</div>
<div>&nbsp; &nbsp; Name, `</div>
<div>&nbsp; &nbsp; DistinguishedName, `</div>
<div>&nbsp; &nbsp; ExchangeObjectId, `</div>
<div>&nbsp; &nbsp; Guid `</div>
<div>| Export-CSV ($WorkingDirectory + &#8220;DG_Details_Backup.csv&#8221;) -NoTypeInformation</div>
<div>sleep 20</div>
<div>&nbsp; &nbsp; }</div>
<div>else {</div>
<div>&nbsp; &nbsp; Write-Host &#8220;There are no appropriate Distribution Lists to migrate. &nbsp;Cancelling migration.&#8221;</div>
<div>&nbsp; &nbsp; Break</div>
<div>}</div>
<div>Write-Host &#8220;Completed&#8221; -ForegroundColor Green</div>
<div>Write-Host &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221; -ForegroundColor Cyan</div>
<div>Write-Host &#8220;Creating a backup of Distribution List Membership and placing in the Working Directory&#8221; -ForegroundColor Green</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div># Export all the Distribution Group Members to a separate file</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div>$output = @()</div>
<div>$Identities = import-csv ($WorkingDirectory + &#8220;DG_Details_Backup.csv&#8221;) | select Name,PrimarySmtpAddress,Managedby,GroupType,RecipientType</div>
<div>If ($Identities) {</div>
<div>Foreach($group in $Identities) {</div>
<div>&nbsp; &nbsp; $Members = Get-DistributionGroupMember $group.PrimarySmtpAddress -resultsize unlimited</div>
<div>&nbsp; &nbsp; if (@($Members.count) -eq 0) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; #$managers = ($group | Select @{Name=&#8217;DistributionGroupManagers&#8217;;Expression={[string]::join(&#8220;;&#8221;, ($_.Managedby))}})</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj = New-Object PSObject</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;DisplayName&#8221; -Value EmptyGroup</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Alias&#8221; -Value EmptyGroup</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;RecipientType&#8221; -Value EmptyGroup</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Recipient OU&#8221; -Value EmptyGroup</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Primary SMTP address&#8221; -Value EmptyGroup</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Distribution Group&#8221; -Value $group.Name</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Distribution Group Primary SMTP address&#8221; -Value $group.PrimarySmtpAddress</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Distribution Group Managers&#8221; -Value $managers.DistributionGroupManagers</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Distribution Group Type&#8221; -Value $group.GroupType</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Distribution Group Recipient Type&#8221; -Value $group.RecipientType</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $output+=$UserObj</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; else {</div>
<div>&nbsp; &nbsp; Foreach($Member in $members) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; #$managers = $group | Select @{Name=&#8217;DistributionGroupManagers&#8217;;Expression={[string]::join(&#8220;;&#8221;, ($_.Managedby))}}</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj = New-Object PSObject</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;DisplayName&#8221; -Value $Member.Name</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Alias&#8221; -Value $Member.Alias</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;RecipientType&#8221; -Value $Member.RecipientType</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Recipient OU&#8221; -Value $Member.OrganizationalUnit</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Primary SMTP address&#8221; -Value $Member.PrimarySmtpAddress</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Distribution Group&#8221; -Value $group.Name</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Distribution Group Primary SMTP address&#8221; -Value $group.PrimarySmtpAddress</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Distribution Group Managers&#8221; -Value $managers.DistributionGroupManagers</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Distribution Group Type&#8221; -Value $group.GroupType</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $userObj | Add-Member NoteProperty -Name &#8220;Distribution Group Recipient Type&#8221; -Value $group.RecipientType</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $output+=$UserObj</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp;}</div>
<div>&nbsp; &nbsp;# We don&#8217;t want to overwrite an existing backup set &#8211; rename any existing files with a time stamp</div>
<div>&nbsp; &nbsp; if (Test-Path ($WorkingDirectory + &#8220;DG_Members_Backup.csv&#8221;)) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $filename = ($WorkingDirectory + &#8220;DG_Members_Backup.csv&#8221;)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $fileObj = get-item $filename</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $DateStamp = get-date -uformat &#8220;%Y-%m-%d@%H-%M-%S&#8221;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $extOnly = $fileObj.extension</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; if ($extOnly.length -eq 0) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $nameOnly = $fileObj.Name</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rename-item &#8220;$fileObj&#8221; &#8220;$nameOnly-$DateStamp&#8221;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; else {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $nameOnly = $fileObj.Name.Replace( $fileObj.Extension,&#8221;)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rename-item &#8220;$fileName&#8221; &#8220;$nameOnly-$DateStamp$extOnly&#8221;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; $output | Export-CSV ($WorkingDirectory + &#8220;DG_Members_Backup.csv&#8221;) -NoTypeInformation</div>
<div>&nbsp; &nbsp;}</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</div>
<div>sleep 15</div>
<div>Write-Host &#8220;Completed&#8221; -ForegroundColor Green</div>
<div>Write-Host &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221; -ForegroundColor Cyan</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div># Create the Cloud copies of the Distribution Lists</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div>Write-Host &#8220;Creating Cloud copies of each AD Synced Distribution List&#8221; -ForegroundColor Green</div>
<div>$Identities = import-csv ($WorkingDirectory + &#8220;DG_Details_Backup.csv&#8221;) | select -expandproperty PrimarySmtpAddress</div>
<div># Create the cloud versions</div>
<div>If ($Identities) {</div>
<div>&nbsp; &nbsp; foreach ($group in $identities) {</div>
<div>&nbsp; &nbsp; If (((Get-DistributionGroup $group -Resultsize Unlimited -ErrorAction &#8216;SilentlyContinue&#8217;).IsValid) -eq $true) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $OldDG = Get-DistributionGroup $group</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; [System.IO.Path]::GetInvalidFileNameChars() | ForEach {$Group = $Group.Replace($_,&#8217;_&#8217;)}</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $OldName = [string]$OldDG.Name</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $OldDisplayName = [string]$OldDG.DisplayName</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $OldPrimarySmtpAddress = [string]$OldDG.PrimarySmtpAddress</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $OldAlias = [string]$OldDG.Alias</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((![string]$OldDG.managedby) -or ([string]$OldDG.managedby -eq &#8220;Organization Management&#8221;)) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [string]$OldDG.managedby=$ManagedByDefault</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $OldMembers = (Get-DistributionGroupMember $OldDG.PrimarySmtpAddress).primarysmtpaddress &#8220;EmailAddress&#8221; &gt; &#8220;$ExportDirectory\$OldName.csv&#8221;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $OldDG.EmailAddresses &gt;&gt; &#8220;$ExportDirectory\$OldName.csv&#8221;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &#8220;x500:&#8221;+$OldDG.LegacyExchangeDN &gt;&gt; &#8220;$ExportDirectory\$OldName.csv&#8221;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; Write-Host &#8221; &nbsp;Creating Group: Cloud-$OldDisplayName&#8221; -ForegroundColor Green</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; New-DistributionGroup `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -Name &#8220;Cloud-$OldName&#8221; `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -Alias &#8220;Cloud-$OldAlias&#8221; `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -DisplayName &#8220;Cloud-$OldDisplayName&#8221; `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -ManagedBy $OldDG.ManagedBy `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -Members $OldMembers `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -PrimarySmtpAddress &#8220;Cloud-$OldPrimarySmtpAddress&#8221; | Out-Null</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; Sleep -Seconds 3</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; Write-Host &#8221; &nbsp;Setting Values For: Cloud-$OldDisplayName&#8221; -ForegroundColor Green</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; Set-DistributionGroup `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -Identity &#8220;Cloud-$OldPrimarySmtpAddress&#8221; `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -AcceptMessagesOnlyFromSendersOrMembers $OldDG.AcceptMessagesOnlyFromSendersOrMembers `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -RejectMessagesFromSendersOrMembers $OldDG.RejectMessagesFromSendersOrMembers `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; Set-DistributionGroup `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -Identity &#8220;Cloud-$OldPrimarySmtpAddress&#8221; `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -AcceptMessagesOnlyFrom $OldDG.AcceptMessagesOnlyFrom `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -AcceptMessagesOnlyFromDLMembers $OldDG.AcceptMessagesOnlyFromDLMembers `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -BypassModerationFromSendersOrMembers $OldDG.BypassModerationFromSendersOrMembers `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -BypassNestedModerationEnabled $OldDG.BypassNestedModerationEnabled `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -CustomAttribute1 $OldDG.CustomAttribute1 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -CustomAttribute2 $OldDG.CustomAttribute2 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -CustomAttribute3 $OldDG.CustomAttribute3 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -CustomAttribute4 $OldDG.CustomAttribute4 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -CustomAttribute5 $OldDG.CustomAttribute5 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -CustomAttribute6 $OldDG.CustomAttribute6 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -CustomAttribute7 $OldDG.CustomAttribute7 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -CustomAttribute8 $OldDG.CustomAttribute8 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -CustomAttribute9 $OldDG.CustomAttribute9 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -CustomAttribute10 $OldDG.CustomAttribute10 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -CustomAttribute11 $OldDG.CustomAttribute11 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -CustomAttribute12 $OldDG.CustomAttribute12 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -CustomAttribute13 $OldDG.CustomAttribute13 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -CustomAttribute14 $OldDG.CustomAttribute14 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -CustomAttribute15 $OldDG.CustomAttribute15 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -ExtensionCustomAttribute1 $OldDG.ExtensionCustomAttribute1 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -ExtensionCustomAttribute2 $OldDG.ExtensionCustomAttribute2 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -ExtensionCustomAttribute3 $OldDG.ExtensionCustomAttribute3 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -ExtensionCustomAttribute4 $OldDG.ExtensionCustomAttribute4 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -ExtensionCustomAttribute5 $OldDG.ExtensionCustomAttribute5 `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -GrantSendOnBehalfTo $OldDG.GrantSendOnBehalfTo `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -HiddenFromAddressListsEnabled $True `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -MailTip $OldDG.MailTip `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -MailTipTranslations $OldDG.MailTipTranslations `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -MemberDepartRestriction $OldDG.MemberDepartRestriction `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -MemberJoinRestriction $OldDG.MemberJoinRestriction `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -ModeratedBy $OldDG.ModeratedBy `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -ModerationEnabled $OldDG.ModerationEnabled `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -RejectMessagesFrom $OldDG.RejectMessagesFrom `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -RejectMessagesFromDLMembers $OldDG.RejectMessagesFromDLMembers `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -ReportToManagerEnabled $OldDG.ReportToManagerEnabled `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -ReportToOriginatorEnabled $OldDG.ReportToOriginatorEnabled `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -RequireSenderAuthenticationEnabled $OldDG.RequireSenderAuthenticationEnabled `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -SendModerationNotifications $OldDG.SendModerationNotifications `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -SendOofMessageToOriginatorEnabled $OldDG.SendOofMessageToOriginatorEnabled `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -BypassSecurityGroupManagerCheck</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; sleep 3</div>
<div>&nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
<div>&nbsp; &nbsp; Else {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; Write-Host &#8221; &nbsp;ERROR: The distribution group &#8216;$Group&#8217; was not found&#8221; -ForegroundColor Red</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; Write-Host</div>
<div>&nbsp; &nbsp; }</div>
<div>}</div>
<div>}</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div># Delete all the Distribution Groups in Active Directory</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div>Write-Host &#8220;All Distribution Lists have been replicated in the Cloud with Cloud_ as a prefix&#8221; -ForegroundColor Green</div>
<div>Write-Host &#8220;Completed&#8221; -ForegroundColor Green</div>
<div>Write-Host &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221; -ForegroundColor Cyan</div>
<div>Write-host &#8220;If you encountered any errors during the creation of the Cloud-Group process you may hit CTRL + C now to kill the process.&#8221; -ForegroundColor Red -BackgroundColor Black</div>
<div>Write-host &#8220;If you kill the process now to fix any issues you should remove the Cloud-Group objects from Azure AD and start fresh.&#8221; -ForegroundColor Red -BackgroundColor Black</div>
<div>Write-host &#8220;WARNING &#8211; The Azure AZ Connect Sync Schedule is currently Suspended. You must complete the script or manually restart the Schedule.&#8221; -ForegroundColor Black -BackgroundColor Red</div>
<div>Write-Host &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221; -ForegroundColor Cyan</div>
<div>Write-host &#8220;Press Enter to delete the migrated Distribution Lists from Active Directory&#8221; -ForegroundColor Cyan</div>
<div>pause</div>
<div>If (test-path ($WorkingDirectory + &#8220;DG_Details_Backup.csv&#8221;)) {</div>
<div>&nbsp; &nbsp; $Identities = import-csv ($WorkingDirectory + &#8220;DG_Details_Backup.csv&#8221;) | select -expandproperty Identity</div>
<div>&nbsp; &nbsp; foreach ($group in $identities) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; Remove-ADGroup -identity &#8220;$group&#8221; -confirm:$false</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; sleep 2</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>}</div>
<div>Write-Host &#8220;All Distribution Lists have been removed from Active Directory&#8221; -ForegroundColor Green</div>
<div>Write-Host &#8220;Completed&#8221; -ForegroundColor Green</div>
<div>Write-Host &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221; -ForegroundColor Cyan</div>
<div>sleep 15</div>
<div>Pause</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div># Initiate a Delta Sync with Azure AD Connect and set a timer of 5 minutes</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div>Write-Host &#8220;Synchronizing Changes with Azure AD Connect. &nbsp;Please allow 5 minutes for process to complete. &nbsp;You will be prompted when to continue.&#8221; -ForegroundColor Green</div>
<div>Start-AdSyncSyncCycle -PolicyType Delta</div>
<div>Write-Host &#8220;PLEASE BE PATIENT &#8211; Confirm the Distribution Lists have been removed from Office 365 Azure AD before continuing&#8221; -ForegroundColor Green</div>
<div>sleep 300</div>
<div>Write-Host &#8220;Completed&#8221; -ForegroundColor Green</div>
<div>Write-Host &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221; -ForegroundColor Cyan</div>
<div>Pause</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div># Complete the process by renaming the Cloud copies to the original names</div>
<div># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div>Write-Host &#8220;Updating the placeholder Distribution Lists to replace the original AD synchronized Distribution Lists&#8221; -ForegroundColor Green</div>
<div>If (test-path $ExportDirectory) {</div>
<div>&nbsp; &nbsp; $Identities = import-csv ($WorkingDirectory + &#8220;DG_Details_Backup.csv&#8221;) | select -expandproperty Identity</div>
<div>&nbsp; &nbsp; foreach ($group in $identities) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $TempDG = Get-DistributionGroup &#8220;Cloud-$Group&#8221;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $TempPrimarySmtpAddress = $TempDG.PrimarySmtpAddress</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; [System.IO.Path]::GetInvalidFileNameChars() | ForEach {$Group = $Group.Replace($_,&#8217;_&#8217;)}</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $OldAddresses = @(Import-Csv &#8220;$ExportDirectory\$Group.csv&#8221;)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $NewAddresses = $OldAddresses | ForEach {$_.EmailAddress.Replace(&#8220;X500&#8243;,&#8221;x500&#8221;)}</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $NewDGName = $TempDG.Name.Replace(&#8220;Cloud-&#8220;,&#8221;&#8221;)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $NewDGDisplayName = $TempDG.DisplayName.Replace(&#8220;Cloud-&#8220;,&#8221;&#8221;)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $NewDGAlias = $TempDG.Alias.Replace(&#8220;Cloud-&#8220;,&#8221;&#8221;)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; $NewPrimarySmtpAddress = ($NewAddresses | Where {$_ -clike &#8220;SMTP:*&#8221;}).Replace(&#8220;SMTP:&#8221;,&#8221;&#8221;)</div>
<div>&nbsp; &nbsp; Write-Host &#8220;Converting Cloud-$Group to $Group&#8221;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; Set-DistributionGroup `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -Identity $TempDG.Name `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -Name $NewDGName `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -Alias $NewDGAlias `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -DisplayName $NewDGDisplayName `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -PrimarySmtpAddress $NewPrimarySmtpAddress `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -HiddenFromAddressListsEnabled $False `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -BypassSecurityGroupManagerCheck</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; Set-DistributionGroup `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -Identity $NewDGName `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -EmailAddresses @{Add=$NewAddresses} `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -BypassSecurityGroupManagerCheck</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; Set-DistributionGroup `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -Identity $NewDGName `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -EmailAddresses @{Remove=$TempPrimarySmtpAddress} `</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -BypassSecurityGroupManagerCheck</div>
<div>&nbsp; &nbsp; sleep 3</div>
<div>&nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; }</div>
<div>Write-Host &#8220;Completed&#8221; -ForegroundColor Green</div>
<div>Write-Host &#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221; -ForegroundColor Cyan</div>
<div># Re-Enable AD Sync Schedule</div>
<div>Set-ADSyncScheduler -SyncCycleEnabled $true</div>
<div>Write-Host &#8220;The conversion process happens in Exchange and can take a while to reflect in Azure AD&#8221;</div>
<div>Write-Host &#8220;Check to make sure that Azure AD is updated and now showing all of the Distribution Lists are converted to Cloud objects&#8221;</div>
<div>Pause</div>
</div>
</blockquote>
<div>
<div>&nbsp;</div>
</div>
<p>The post <a href="https://catastrophe.wiredwolf.com/office-365-migrating-distribution-groups/">Office 365 &#8211; Migrating Distribution Groups</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Azure AD Connect &#8211; Fixing the Sync</title>
		<link>https://catastrophe.wiredwolf.com/azure-ad-connect-fixing-the-sync/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 17 May 2023 17:03:54 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[Microsoft Office 365]]></category>
		<category><![CDATA[Microsoft Server]]></category>
		<guid isPermaLink="false">https://catastrophe.wiredwolf.com/?p=22432</guid>

					<description><![CDATA[<p>Windows Active Directory to Azure Active Directory generally works pretty well but there are times when the sync generates a new Azure AD user instead of linking to an existing account in Azure.  This generally happens when you're onboarding a client environment to Azure where they already have a number of accounts in MS 365  [...]</p>
<p>The post <a href="https://catastrophe.wiredwolf.com/azure-ad-connect-fixing-the-sync/">Azure AD Connect &#8211; Fixing the Sync</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Windows Active Directory to Azure Active Directory generally works pretty well but there are times when the sync generates a new Azure AD user instead of linking to an existing account in Azure.&nbsp; This generally happens when you&#8217;re onboarding a client environment to Azure where they already have a number of accounts in MS 365 that are in use, and now need to be directly linked to the on-premises Active Directory.</p>
<p>Typically I use the EmailAddress (Mail) attribute to cross-link the accounts.</p>
<p>Example:</p>
<p>Azure AD user:&nbsp; Smiles J. McDuff</p>
<p>Azure AD email:&nbsp; smiley@mydomain.com, sjmcduff@mydomain.onmicrosoft.com</p>
<p>In AD I then create the user &#8211;</p>
<p>AD User:&nbsp; &nbsp;Smiles McDuff</p>
<p>SamAccountName:&nbsp; sjmcduff</p>
<p>Set Email Address:&nbsp; smiley@mydomain.com</p>
<p>When I do an Azure AD Connect Sync the new AD user should match to the Azure AD user and overwrite the user and attributes to that based in Active Directory.</p>
<p>Sometimes that doesn&#8217;t happen, such as making a typo with the email address, and instead of cross-linking the accounts between AD and AAD, a new user account is created in AAD.&nbsp; Now things get tricky, because no matter how many times you delete the incorrect account in Azure AD, the next sync will just recreate it.</p>
<p>The solution is to capture the ObjectGUID attribute for the user in Active Directory and set that as the ImmutableID for the user in Azure.</p>
<p>Command:</p>
<blockquote><p>Get-ADUser sjmcduff | select-object userPrincipalName, objectGuid</p></blockquote>
<p>Result:</p>
<blockquote><p>UserPrincipleName&nbsp; :&nbsp; sjmcduff@mywindowsdomain.com</p>
<p>objectGuid : b316d357-25fd-4912-9896-faf007a16289</p></blockquote>
<p>Now convert that Guid to something we can use as an ImmutableID &#8211;</p>
<blockquote><p>[Convert]::ToBase64String([guid]::New(&#8220;b316d357-25fd-4912-9896-faf007a16289&#8221;).ToByteArray())</p></blockquote>
<p>Result:&nbsp;&nbsp;</p>
<blockquote><p>V9MWs/0lEkmYlvrwB6FiiQ==</p></blockquote>
<p>This is our new ImmutableID value for the Azure AD user account.</p>
<blockquote><p>connect-msolservice</p>
<p>Get-MsolUser -UserPrincipalName &#8220;sjmcduff@mydomain.onmicrosoft.com&#8221; | select-object userPrincipalName, ImmutableId</p></blockquote>
<p>Result:</p>
<blockquote><p>UserPrincipalName : sjmcduff@mydomain.onmicrosoft.com<br />
ImmutableId :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Confirm ImmutableID is blank -if not record it in your notes]</p></blockquote>
<p>Command:</p>
<blockquote><p>Set-MsolUser -UserPrincipalName &#8220;sjmcduff@mydomain.onmicrosoft.com&#8221; -ImmutableId &#8220;V9MWs/0lEkmYlvrwB6FiiQ==&#8221;</p></blockquote>
<p>Comand:</p>
<blockquote><p>Get-MsolUser -UserPrincipalName &#8220;sjmcduff@mydomain.onmicrosoft.com&#8221; | fl userPrincipalName,ImmutableId</p></blockquote>
<p><strong><em>Confirm ImmutableID matches</em></strong></p>
<p>Now when you sync, the accounts should pair up properly.</p>
<p>The post <a href="https://catastrophe.wiredwolf.com/azure-ad-connect-fixing-the-sync/">Azure AD Connect &#8211; Fixing the Sync</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PowerShell &#8211; Active Directory &#8211; New Email Domain</title>
		<link>https://catastrophe.wiredwolf.com/powershell-active-directory-new-email-domain/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 15 Aug 2022 17:11:27 +0000</pubDate>
				<category><![CDATA[Microsoft Office 365]]></category>
		<category><![CDATA[Microsoft Server]]></category>
		<category><![CDATA[PowerShell]]></category>
		<guid isPermaLink="false">https://catastrophe.wiredwolf.com/?p=21776</guid>

					<description><![CDATA[<p>Environment: Active Directory with Azure Active Directory Connect and Exchange Online I had a job recently where I needed to change everyone's email address to a new domain but I couldn't accomplish this from Exchange Online as all the users are synchronized with Active Directory on-premises. I wrote a quick script that addresses this: &lt;#  [...]</p>
<p>The post <a href="https://catastrophe.wiredwolf.com/powershell-active-directory-new-email-domain/">PowerShell &#8211; Active Directory &#8211; New Email Domain</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="fusion-fullwidth fullwidth-box fusion-builder-row-1 fusion-flex-container nonhundred-percent-fullwidth non-hundred-percent-height-scrolling" style="--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-flex-wrap:wrap;" ><div class="fusion-builder-row fusion-row fusion-flex-align-items-flex-start fusion-flex-content-wrap" style="max-width:1144px;margin-left: calc(-4% / 2 );margin-right: calc(-4% / 2 );"><div class="fusion-layout-column fusion_builder_column fusion-builder-column-0 fusion_builder_column_1_1 1_1 fusion-flex-column" style="--awb-bg-size:cover;--awb-width-large:100%;--awb-margin-top-large:0px;--awb-spacing-right-large:1.92%;--awb-margin-bottom-large:0px;--awb-spacing-left-large:1.92%;--awb-width-medium:100%;--awb-spacing-right-medium:1.92%;--awb-spacing-left-medium:1.92%;--awb-width-small:100%;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;"><div class="fusion-column-wrapper fusion-flex-justify-content-flex-start fusion-content-layout-column"><div class="fusion-text fusion-text-1"><p>Environment: Active Directory with Azure Active Directory Connect and Exchange Online</p>
<p>I had a job recently where I needed to change everyone's email address to a new domain but I couldn't accomplish this from Exchange Online as all the users are synchronized with Active Directory on-premises. </p>
<p>I wrote a quick script that addresses this:</p>
<blockquote>
<p><#<br />
PowerShell<br />
Objectives<br />
– query AD with all users with a 'mail' attribute<br />
– update the 'mail' attribute to the new domain<br />
– set the proxyaddress SMTP matching the mail attribute to lowercase smtp<br />
– set the proxyaddress SMTP to the new domain</p>
<p>Author: Jason Zondag<br />
Date: 2202.08.11<br />
#><br />
# Set Variables<br />
$newMailDomain = "newdomain.com"<br />
$oldMailDomain = "olddomain.com"</p>
<p># Make sure we have AD access<br />
Import-Module ActiveDirectory</p>
<p># Set the SearchBase<br />
$SearchBase = "DC=domain,DC=local"</p>
<p># Get the required data and loop<br />
$Users = Get-ADUser -Filter "mail -like '*'" -SearchBase "$SearchBase" -ResultSetSize $null -properties mail,proxyaddresses,samaccountname,givenname,sn<br />
ForEach ($User in $Users) </p>
</blockquote>
<p>Note – you must run this script with elevated privileges. </p>
<p>I would also recommend that you add the command to stop AAD Sync during the course of running the script.</p>
</div></div></div></div></div>
<p>The post <a href="https://catastrophe.wiredwolf.com/powershell-active-directory-new-email-domain/">PowerShell &#8211; Active Directory &#8211; New Email Domain</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PowerShell &#8211; Installing Modules</title>
		<link>https://catastrophe.wiredwolf.com/powershell-installing-modules/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 05 Aug 2021 18:16:13 +0000</pubDate>
				<category><![CDATA[Microsoft Office 365]]></category>
		<category><![CDATA[Microsoft Server]]></category>
		<category><![CDATA[PowerShell]]></category>
		<guid isPermaLink="false">https://catastrophe.wiredwolf.com/?p=20974</guid>

					<description><![CDATA[<p>PowerShell is continuing to evolve.  Occasionally I come across a server that I need to install modules to and find that I cannot.  Windows Management Framework 5.1 is installed to Server 2016/2019 out of the box but it's not directly equipped to be caught up - you need to do some steps first. Open PowerShell  [...]</p>
<p>The post <a href="https://catastrophe.wiredwolf.com/powershell-installing-modules/">PowerShell &#8211; Installing Modules</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>PowerShell is continuing to evolve.&nbsp; Occasionally I come across a server that I need to install modules to and find that I cannot.&nbsp; Windows Management Framework 5.1 is installed to Server 2016/2019 out of the box but it&#8217;s not directly equipped to be caught up &#8211; you need to do some steps first.</p>
<ol>
<li>Open PowerShell (as Administrator is also an option)</li>
<li>Copy/Paste:&nbsp; &nbsp;Set-ExecutionPolicy Unrestricted
<ol>
<li>Execute</li>
</ol>
</li>
<li>Copy/Paste:&nbsp; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
<ol>
<li>Execute</li>
</ol>
</li>
<li>Copy/Paste:&nbsp; Register-PSRepository -Default
<ol>
<li>Execute</li>
</ol>
</li>
<li>Copy/Paste:&nbsp; Update-Module PowerShellGet -Force
<ol>
<li>Execute</li>
</ol>
</li>
</ol>
<p>At this point you should be in good shape to add whatever modules it is you are trying to install from the repository.&nbsp;</p>
<ul>
<li>Install-Module AzureAD</li>
<li>Install-Module ExchangeOnlineManagement</li>
<li>etc</li>
</ul>
<p>&nbsp;</p>
<p>The post <a href="https://catastrophe.wiredwolf.com/powershell-installing-modules/">PowerShell &#8211; Installing Modules</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Dynamic Distribution Lists</title>
		<link>https://catastrophe.wiredwolf.com/dynamic-distribution-lists/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 08 Jun 2021 01:13:44 +0000</pubDate>
				<category><![CDATA[Microsoft Exchange]]></category>
		<category><![CDATA[Microsoft Office 365]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[Office 365]]></category>
		<guid isPermaLink="false">https://catastrophe.wiredwolf.com/?p=20957</guid>

					<description><![CDATA[<p>Dynamic Distribution Lists are an easy way to maintain lists without having to constantly maintain lists.  Basic creation is simple - you can do that right from EAC and select which type of recipients in the organization should be included.   More complex options exist but are accomplished with PowerShell.  For instance, you want to create  [...]</p>
<p>The post <a href="https://catastrophe.wiredwolf.com/dynamic-distribution-lists/">Dynamic Distribution Lists</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Dynamic Distribution Lists are an easy way to maintain lists without having to constantly maintain lists.&nbsp;</p>
<p>Basic creation is simple &#8211; you can do that right from EAC and select which type of recipients in the organization should be included.&nbsp;&nbsp;</p>
<p>More complex options exist but are accomplished with PowerShell.&nbsp; For instance, you want to create a distribution list that includes all Exchange Mailbox users, but you don&#8217;t want to include Shared Mailboxes, Equipment or Resource Mailboxes, or any users with attributes that match.&nbsp;&nbsp;</p>
<p>If you want to use custom attributes where you have AAD Connect there&#8217;s a bit more you need to do.&nbsp; I&#8217;ve document that here: <a href="https://catastrophe.wiredwolf.com/azure-ad-connect-and-custom-attributes/">https://catastrophe.wiredwolf.com/azure-ad-connect-and-custom-attributes/</a></p>
<p>This is where it gets a bit tricky.&nbsp; You can&#8217;t mix operators and stay sane, so it&#8217;s important to know how to format the command with not double not nor negatives (joke).</p>
<p>Creating a List:</p>
<p style="padding-left: 40px;">New-dynamicdistributiongroup -name&nbsp;&#8220;<strong><span style="color: #ff6600;">DGNAME</span></strong>&#8221; `<br />
-recipientfilter {((RecipientType -eq &#8216;UserMailbox&#8217;) `<br />
-and (CustomAttribute1 -ne &#8216;<span style="color: #ff6600;">NoMember</span>&#8216;) `<br />
-and (-not(RecipientTypeDetailsValue -eq &#8216;SharedMailbox&#8217;)) `<br />
-and (-not(RecipientTypeDetailsValue -eq &#8216;GuestMailUser&#8217;)) `<br />
-and (-not(Name -like &#8216;SystemMailbox{*&#8217;)) `<br />
-and (-not(Name -like &#8216;CAS_{*&#8217;)) `<br />
-and (-not(Company -eq &#8216;<span style="color: #ff6600;">Acme</span>&#8216;)) `<br />
-and (-not(RecipientTypeDetailsValue -eq &#8216;MailboxPlan&#8217;)) `<br />
-and (-not(RecipientTypeDetailsValue -eq &#8216;DiscoveryMailbox&#8217;)) `<br />
-and (-not(RecipientTypeDetailsValue -eq &#8216;PublicFolderMailbox&#8217;)) `<br />
-and (-not(RecipientTypeDetailsValue -eq &#8216;ArbitrationMailbox&#8217;)) `<br />
-and (-not(RecipientTypeDetailsValue -eq &#8216;AuditLogMailbox&#8217;)) `<br />
-and (-not(RecipientTypeDetailsValue -eq &#8216;AuxAuditLogMailbox&#8217;)) `<br />
-and (-not(RecipientTypeDetailsValue -eq &#8216;SupervisoryReviewPolicyMailbox&#8217;)))} `<br />
-managedby &#8220;admin@yourdomain.com&#8221; `<br />
-DisplayName &#8220;Dynamic Distribution Group Name&#8221; `<br />
-RequireSenderAuthenticationEnabled $false `<br />
-MemberDepartRestriction closed `<br />
-MemberJoinRestriction closed</p>
<p>I&#8217;ve added a couple of <span style="color: #ff6600;">options</span> as an example of how far you can go with RecipientType and RecipientTypeDetails. If synchronized with an on-premises AD you can easily add attributes to the account, such as Company, or CustomAttribute1, at which point you can use these attributes to further hone the scope of your Dynamic Distribution List.</p>
<p>If you&#8217;ve created the dynamic distribution list already you can always edit it:</p>
<p>replace new-dynamicdistributiongroup -Name &#8220;DGNAME&#8221; with set-dynamicdistributiongroup -identity &#8220;DGNAME&#8221;&nbsp;</p>
<p>Getting details from a single list &#8211; export to CSV</p>
<p>Get-Recipient -RecipientPreviewFilter (get-dynamicdistributiongroup <span style="color: #ff6600;"><strong>DGNAME</strong></span>).RecipientFilter -OrganizationalUnit $group.RecipientContainer | select Name, DisplayName, PrimarySMTPAddress, RecipientType*, WindowsLiveID | export-csv &#8220;C:\CSV-PATH\DynDG-DGNAME.CSV&#8221; -NoTypeInformation</p>
<p>The post <a href="https://catastrophe.wiredwolf.com/dynamic-distribution-lists/">Dynamic Distribution Lists</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PowerShell CMDLET Limitations</title>
		<link>https://catastrophe.wiredwolf.com/powershell-cmdlet-limitations/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 18 Feb 2021 20:26:17 +0000</pubDate>
				<category><![CDATA[Microsoft Office 365]]></category>
		<category><![CDATA[Microsoft Server]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[get-aduser]]></category>
		<category><![CDATA[office365]]></category>
		<guid isPermaLink="false">https://catastrophe.wiredwolf.com/?p=20952</guid>

					<description><![CDATA[<p>It was recently discovered that when new user accounts are set up in AD and then synchronized with Azure AD Connect, there is some 'guessing' that happens around default email address assignment if proper proxyAddresses attributes are not manually added.  Essentially it appears that Microsoft 365 will set the user's UPN or samAccountName as the  [...]</p>
<p>The post <a href="https://catastrophe.wiredwolf.com/powershell-cmdlet-limitations/">PowerShell CMDLET Limitations</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>It was recently discovered that when new user accounts are set up in AD and then synchronized with Azure AD Connect, there is some &#8216;guessing&#8217; that happens around default email address assignment if proper proxyAddresses attributes are not manually added.&nbsp; Essentially it appears that Microsoft 365 will set the user&#8217;s UPN or samAccountName as the default/primary SMTP address.&nbsp;</p>
<p>That&#8217;s fine normally, because typically that&#8217;s the email address you would normally assign the user.&nbsp; That is, until the account is updated with MFA registration information, at which point the default address automatically becomes the @tenant.onmicrosoft.com extension.&nbsp; Then it becomes a big problem as the onmicrosoft.com domain is not typically routable.</p>
<p>When we uncovered this undocumented feature we realized that we were going to have to update all AD accounts where the proxyAddresses attribute field was left blank.&nbsp; Except, how to search for something that isn&#8217;t there on hundreds of accounts?</p>
<p>I discovered through a lot of trail and error that not all operators work with all cmdlets.&nbsp; Get-ADUser, for example, can handle -filter options of -eq -like -match, but cannot handle -ceq -clike or -cmatch, and has no concept at all of -notlike or -notequal.&nbsp; Suddenly the search become considerably more difficult.</p>
<p>I know there&#8217;s going to be a lot of PowerShell experts out there who&#8217;ll look at this and say &#8220;there&#8217;s a better way&#8221; but this was the best I could come up with:</p>
<blockquote><p>get-aduser -filter &#8216;enabled -eq $true&#8217; -Properties Name,DisplayName,SamAccountName,SurName,GivenName,UserPrincipalName,proxyaddresses | `<br />
Select-Object Name, DisplayName, SamAccountName, Surname, GivenName, UserPrincipalName, `<br />
@{n = &#8220;proxyAddress&#8221;; e = { $_.proxyAddresses | Where-object { $_ -clike &#8220;SMTP:*&#8221; } } }</p></blockquote>
<p>I exported the results to a CSV file, then used Excel&#8217;s Data &#8211;&gt; Filter option to filter out all found SMTP entries, leaving only blanks, which gave me the list of accounts to fix.</p>
<p>I was actually hoping to also find a way to filter out all the system accounts, but was satisfied with the AD &#8216;enabled&#8217; accounts.</p>
<p>The post <a href="https://catastrophe.wiredwolf.com/powershell-cmdlet-limitations/">PowerShell CMDLET Limitations</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Automatic Enrollment Issues with Intune</title>
		<link>https://catastrophe.wiredwolf.com/automatic-enrollment-issues-with-intune/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 22 Jan 2021 20:23:45 +0000</pubDate>
				<category><![CDATA[Intune]]></category>
		<category><![CDATA[Microsoft Office 365]]></category>
		<guid isPermaLink="false">https://catastrophe.wiredwolf.com/?p=20941</guid>

					<description><![CDATA[<p>This has been one of the more frustrating Microsoft Issues I've had to deal with recently. The deployment is relatively straightforward. Set up a GPO to deploy to all workstations and make some minor adjustments in the O365 tenant. It's well documented so I won't bother with that here. Just make sure one of the  [...]</p>
<p>The post <a href="https://catastrophe.wiredwolf.com/automatic-enrollment-issues-with-intune/">Automatic Enrollment Issues with Intune</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="fusion-fullwidth fullwidth-box fusion-builder-row-2 nonhundred-percent-fullwidth non-hundred-percent-height-scrolling" style="--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-flex-wrap:wrap;" ><div class="fusion-builder-row fusion-row"><div class="fusion-layout-column fusion_builder_column fusion-builder-column-1 fusion_builder_column_1_1 1_1 fusion-one-full fusion-column-first fusion-column-last" style="--awb-bg-size:cover;--awb-margin-bottom:0px;"><div class="fusion-column-wrapper fusion-flex-column-wrapper-legacy"><div class="fusion-text fusion-text-2"><p>This has been one of the more frustrating Microsoft Issues I&#8217;ve had to deal with recently.  </p>
<p>The deployment is relatively straightforward.  Set up a GPO to deploy to all workstations and make some minor adjustments in the O365 tenant.  It&#8217;s well documented so I won&#8217;t bother with that here.  Just make sure one of the first things you check is that the GPO is being applied to the USER.</p>
<p>The problem is waiting for machines to check in.  Once it&#8217;s all set up you have to wait for the machines to show up in the <a href="https://endpoint.microsoft.com">Microsoft Endpoint</a>.</p>
<p>Devices &#8211;&gt; All Devices</p>
<p>In my case after 2 months on a 60+ PC network spanning 5 sites only 16 machines showed up as being compliant.  </p>
<p>These are the bits that I learned to help facilitate finding information, troubleshooting, and ultimately resolving the issues.</p>
<p>First, it&#8217;s important to note that Intune Deployment <em>does not like</em> when other MDM-type deployments have been applied to the PC.  I guess this makes sense, but in my opinion they should make it easier to figure out what&#8217;s wrong.</p>
<p>Logging for this is found here:  Event Viewer &#8211;&gt; Application and Services Logs &#8211;&gt; Microsoft &#8211;&gt; Windows &#8211;&gt; DeviceManagement-Enterprise-Diagnostics-Provider &#8211;&gt; Admin</p>
<p>Commands:</p>
<p>&#8220;dsregcmd&#8221; is the go-to command for determining the status of the machine with Intune.</p>
<blockquote>
<p>dsregcmd /status</p>
</blockquote>
<p>This tells you the current status of the machine.  </p>
<p><a href="https://docs.microsoft.com/en-us/mem/intune/enrollment/troubleshoot-windows-auto-enrollment">Troubleshoot Windows 10 auto-enrollment in Intune &#8211; Microsoft Intune | Microsoft Docs</a></p>
<p>This site tells you to find these entries:</p>
<ul>
<li>Device State:
<ul>
<li>AzureAdJoined: YES</li>
<li>DomainJoined: YES</li>
</ul>
</li>
<li>SSO State:
<ul>
<li>AzureAdPrt: YES</li>
</ul>
</li>
</ul>
<p>In each machine I checked, both checking in successfully and those not appearing at all in Endpoint, none showed AzureAdPrt: YES.</p>
<p>I didn&#8217;t really find the Microsoft Article to be terribly helpful.</p>
<p>Reviewing the logs gave me the kernel I needed to start searching for why the machines weren&#8217;t being picked up.  I stumbled across a number of sites that tried to address it, but were difficult to follow.  </p>
<p>Ultimately I found this process to work:</p>
<ol>
<li>Look in the Registry for an entry in ComputerHKEY_LOCAL_MACHINESOFTWAREMicrosoftEnrollments
<ol>
<li>There will be numerous entries but the majority of them will have only the following sub-entries
<ol>
<li>Altitude</li>
<li>EnrollmentState</li>
<li>EnrollmentType</li>
</ol>
</li>
<li>The entry will be a hexadecimal key like 18DCFFD4-37D6-4BC6-87E0-4266FDBB8E49 but they appear to be pretty random so check them all</li>
<li>The entry we&#8217;re looking for will have way more information in it
<ol>
<li>AADOpaqueID</li>
<li>AADResourceID</li>
<li>CurKeyContainer</li>
<li>DiscoveryService&#8230;</li>
<li>ProviderID</li>
<li>UPN</li>
<li>Etc&#8230;</li>
</ol>
</li>
<li>Delete this key and any others like it
</li>
<ol>
<li>It&#8217;s possible there will be more than one &#8211; check them all</li>
</ol>
<li>Execute this command on the affected workstation:   <b>dsregcmd /leave</b></li>
<li>Reboot the PC</li>
</ol>
</li>
<li>Locate the PC in Azure AD under Devices and delete it</li>
<li>Re-run the AD Sync &#8211; PowerShell Command:
<ol>
<li><b>Start-ADSyncSyncCycle -PolicyType Delta</b></li>
</ol>
<ol>
<li>Wait for the Sync to complete and give Azure AD a couple of minutes to pick up the changes</li>
</ol>
</li>
<li>Log in to the PC and open a CMD prompt and re-run &#8220;<b>gpupdate /force</b>&#8220;</li>
<li>Run <b>dsregcmd /status<br />
</b></p>
<ol>
<li>The status should not show any connectivity (URL/URI entries) to Office yet but they will populate</li>
</ol>
</li>
<li>Log out of the PC and wait for the licensed Intune user to log in</li>
<li>Check status of Endpoint &#8211; the PC should now be showing up</li>
</ol>
</div><div class="fusion-clearfix"></div></div></div></div></div>
<p>The post <a href="https://catastrophe.wiredwolf.com/automatic-enrollment-issues-with-intune/">Automatic Enrollment Issues with Intune</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SPF &#8211; DKIM &#8211; DMARC</title>
		<link>https://catastrophe.wiredwolf.com/spf-dkim-dmarc/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 19 Jan 2021 07:21:08 +0000</pubDate>
				<category><![CDATA[DNS]]></category>
		<category><![CDATA[Microsoft Exchange]]></category>
		<category><![CDATA[Microsoft Office 365]]></category>
		<guid isPermaLink="false">https://catastrophe.wiredwolf.com/?p=20939</guid>

					<description><![CDATA[<p>Email security has been a 'thing' now for quite a while.  Try sending email from unsecured domains and you'll get a lot of rejection letters. If you have Office 365 and you're actively using Exchange online then with just a few steps you can secure your mail properly. Set up SPF SPF is Sender Policy  [...]</p>
<p>The post <a href="https://catastrophe.wiredwolf.com/spf-dkim-dmarc/">SPF &#8211; DKIM &#8211; DMARC</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Email security has been a &#8216;thing&#8217; now for quite a while.&nbsp; Try sending email from unsecured domains and you&#8217;ll get a lot of rejection letters.</p>
<p>If you have Office 365 and you&#8217;re actively using Exchange online then with just a few steps you can secure your mail properly.</p>
<h4>Set up SPF</h4>
<p>SPF is Sender Policy Framework and it basically tells the Internet where email from your domain is legitimately sent from.&nbsp; When a receiving MTA does a check it sees the IP your email originated from then compares that to the SPF record in your DNS Zone.&nbsp; If the IP or FQDN or MX doesn&#8217;t match &#8211; your mail could be blocked.&nbsp;</p>
<p>Setting up SPF is simple and Microsoft gives you what you need right in the tenant.</p>
<ul>
<li>Log in to your Tenant as a Global Administrator</li>
<li>Open Settings &#8211; Domains</li>
<li>Select your primary domain (the one you mail from)</li>
<li>Click on DNS</li>
<li>Copy/paste the TXT record for SPF to Notepad</li>
</ul>
<p>Note &#8211; if you have an email sender on your domain that is not sending through Office 365 you need to update the record to reflect that source.</p>
<p>Typical SPF record:&nbsp; &nbsp;<strong>&#8220;v=spf1 include:spf.protection.outlook.com -all&#8221;</strong></p>
<p>Here&#8217;s an SPF where you&#8217;ve added another source location for email:&nbsp; &#8220;v=spf1 ip4:208.191.17.213 include:spf.protection.outlook.com -all&#8221; where 208.191.17.213 is the public IP of your office where you have a photocopier that sends email</p>
<h4>Set up DKIM</h4>
<p>DKIM is a bit harder to understand.&nbsp; Domain Keys Identified Mail is a domain-level digital signature authentication framework that basically validates the DNS source against a signature from the MTA to validate the authenticity of the mail.&nbsp; Primarily this is to prevent spoofing, where an outside source sends mail through the MTA (Message Transfer Agent) designed to look like it came from your domain.&nbsp; DKIM adds headers to every outbound email that are checked against the DNS servers for your domain to validate the source which can be checked against the recipient MTA.</p>
<p>In this way both the MTA is validating against SPF and DKIM to verify the authenticity of the source of the email.&nbsp; By the way, both are required to set up DMARC which we&#8217;ll get to in a bit.</p>
<p>Setting up DKIM is actually fairly simple.</p>
<p>Let&#8217;s say the domain registered in your MS Tenant is gotmilk.ca.</p>
<p style="padding-left: 40px;">Crack open your PowerShell and connect to Exchange Online</p>
<blockquote>
<p style="padding-left: 40px;">connect-exchangeonline</p>
</blockquote>
<p style="padding-left: 40px;">Run a simple command to pull the DKIM records you&#8217;ll need:</p>
<blockquote>
<p style="padding-left: 40px;">get-dkimsigningconfig -identity gotmilk.ca | select domain,selector*CNAME</p>
<p>You&#8217;ll get a result that looks like this:</p>
<p>Domain Selector1CNAME Selector2CNAME<br />
&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8211;<br />
gotmilk.ca selector1-gotmilk-ca._domainkey.gotmilk.onmicrosoft.com selector2-gotmilk-ca._domainkey.gotmilk.onmicrosoft.com</p></blockquote>
<p style="padding-left: 40px;">Copy/Paste the results to the Notepad document where you put your SPF record</p>
<h4>Update DNS</h4>
<p>Now it&#8217;s time to update your DNS Zone records.&nbsp; We&#8217;ll continue to use gotmilk.ca for our examples. Go to your DNS server and create the following records:</p>
<p>@ (domain root) TXT&nbsp; <strong>&#8220;v=spf1 include:spf.protection.outlook.com -all&#8221;</strong></p>
<p>selector1._domainkey.gotmilk.ca <strong>CNAME</strong> gotmilk.ca selector1-gotmilk-ca._domainkey.gotmilk.onmicrosoft.com</p>
<p>selector2._domainkey.gotmilk.ca <strong>CNAME</strong> selector2-gotmilk-ca._domainkey.gotmilk.onmicrosoft.com</p>
<p>While you&#8217;re there create the DMARC record</p>
<p>_dmarc.gotmilk.ca <strong>TXT</strong> &#8220;v=DMARC1; pct=100; p=quarantine&#8221;</p>
<p>Office 365</p>
<p>Time to complete the setup in Office 365.&nbsp;</p>
<ul>
<li>Log in to your Exchange Admin Center and go to protection &#8211;&gt; DKIM</li>
<li>Highlight the domain gotmilk.ca and click on Enable in the action pane on the right
<ul>
<li>If the two CNAME records you created above have propagated DKIM should enable successfully on the domain</li>
<li>Click on Rotate</li>
</ul>
</li>
<li>Open the Spam Filter and double click on the Default policy</li>
<li>Open Advanced Options</li>
<li>Enable two options:
<ul>
<li>SPF record: hard fail</li>
<li>Conditional Sender ID filtering: hard fail</li>
</ul>
</li>
</ul>
<p>That&#8217;s it! SPF, DKIM, and DMARC are now enabled and protecting your domain from general maliciousness.</p>
<p>DMARC has a number of additional options you can enable in the form of tags:</p>
<h3>Declared tags</h3>
<table class="table table-bordered">
<tbody>
<tr>
<th width="80">Tag</th>
<th width="80">Value</th>
<th>Description</th>
</tr>
<tr>
<td class="success">v</td>
<td class="success">DKIM1</td>
<td class="success">DKIM protocol version.</td>
</tr>
<tr>
<td class="success">p</td>
<td class="success">MIGfMA0GCSqGSIb3DQEBAQUAA&#8230;</td>
<td class="success">Your base64 encoded public key.</td>
</tr>
<tr>
<td class="success">k</td>
<td class="success">rsa</td>
<td class="success">The &#8216;k=&#8217; tag provide a list of mechanisms that can be used to decode a DKIM signature. (&#8216;rsa&#8217; is used most often)</td>
</tr>
</tbody>
</table>
<h3>Defaulted tags</h3>
<table class="table table-bordered">
<tbody>
<tr>
<th width="80">Tag</th>
<th width="80">Value</th>
<th>Description</th>
</tr>
<tr>
<td>g</td>
<td>*</td>
<td>Some organizations assign specific business functions to discrete groups, inside or outside the organization. This key is to authorize that group to sign some mail, but to constrain what signatures they can generate. The DKIM granularity (the &#8216;g=&#8217; tag) facilitate this kind of restricted authorization.</td>
</tr>
<tr>
<td>h</td>
<td>&nbsp;</td>
<td>The &#8216;h=&#8217; tag provide a list of mechanisms that can be used to produce a digest of message data. (&#8216;sha1&#8217; or &#8216;sha256&#8217; can be used).</td>
</tr>
<tr>
<td>n</td>
<td>&nbsp;</td>
<td>Notes that might be of interest to a human.</td>
</tr>
<tr>
<td>s</td>
<td>*</td>
<td>The &#8216;s=&#8217; provides a list of service types to which this selector may apply. (&#8216;*&#8217; and &#8217;email&#8217; are used most often)</td>
</tr>
<tr>
<td>t</td>
<td>&nbsp;</td>
<td>The &#8216;t=&#8217; tag provides a list of flags to modify interpretation of the selector. These DKIM Selector Flags for additional flags are optional. (&#8216;y&#8217; and &#8216;s&#8217; are often used)</td>
</tr>
<tr>
<td>q</td>
<td>&nbsp;</td>
<td>The &#8216;q=&#8217; tag-spec provides for a list of query methods. (&#8216;dns&#8217; is used most often)</td>
</tr>
<tr>
<td>l</td>
<td>0</td>
<td>Body length limits (in the form of the &#8216;l=&#8217; tag) are subject to several potential attacks.</td>
</tr>
</tbody>
</table>
<p>The post <a href="https://catastrophe.wiredwolf.com/spf-dkim-dmarc/">SPF &#8211; DKIM &#8211; DMARC</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Office 365 Hybrid to On Premises Exchange &#8211; Mail Flow How-To</title>
		<link>https://catastrophe.wiredwolf.com/office-365-hybrid-to-on-premises-exchange-mail-flow-how-to/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 20 Apr 2020 23:20:59 +0000</pubDate>
				<category><![CDATA[Microsoft Exchange]]></category>
		<category><![CDATA[Microsoft Office 365]]></category>
		<category><![CDATA[Networking]]></category>
		<guid isPermaLink="false">https://catastrophe.wiredwolf.com/?p=20807</guid>

					<description><![CDATA[<p>Migrating to Office 365 can be a time consuming endeavor and require that it be conducted in stages.  When moving batches of mailboxes the On-Prem Exchange server shows the mailboxes as "Remote Mailbox" and while appears to be aware of the mailbox, is not immediately able to route mail between the On-Premises Mailboxes and the  [...]</p>
<p>The post <a href="https://catastrophe.wiredwolf.com/office-365-hybrid-to-on-premises-exchange-mail-flow-how-to/">Office 365 Hybrid to On Premises Exchange &#8211; Mail Flow How-To</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Migrating to Office 365 can be a time consuming endeavor and require that it be conducted in stages.&nbsp; When moving batches of mailboxes the On-Prem Exchange server shows the mailboxes as &#8220;Remote Mailbox&#8221; and while appears to be aware of the mailbox, is not immediately able to route mail between the On-Premises Mailboxes and the Remote Mailboxes.</p>
<p>There are a series of steps that must be taken to ensure mail flow:</p>
<ol>
<li>If using Azure AD Connect and filtering by OU or Security Group &#8211; make sure all mailbox users AD accounts are synchronized to Azure AD/Office 365
<ol>
<li>Add all Mail Users
<ol>
<li>In AD this can be easily accomplished with a simple Powershell script:<br />
<blockquote><p>Get-ADUser -Filter &#8216;Enabled -eq $true -and Mail -like &#8220;*@*&#8221;&#8216; | ForEach-Object {Add-ADGroupMember -Identity &#8216;Office365Users&#8217; -Members $_ }</p></blockquote>
<p><em>Where &#8220;Office365Users&#8221; is your security group</em></li>
</ol>
</li>
<li>Add all Contacts</li>
<li>Add all Distribution Lists</li>
<li>Add all Mail-Enabled Security Groups</li>
</ol>
</li>
</ol>
<p>For mail from&nbsp;<em>from</em> Office 365&nbsp;<em>to</em> Exchange On-Premises (Performed in Office 365 Exchange Admin Center):</p>
<ol>
<li>Create an Internal Relay to On-Prem Exchange connector (in EAC)</li>
</ol>
<p>For mail&nbsp;<em>to</em> Office 365&nbsp;<em>from</em> Exchange On-Premises (Performed in On-Premises Exchange Server):</p>
<ol>
<li>Create a&nbsp;<em>tenant.mail.onmicrosoft.com</em> in Accepted Domains and set to&nbsp;<em>Internal Relay</em></li>
<li>Create an &#8220;<em>O365 Relay</em>&#8221; Send Connector
<ol>
<li>FQDN of the connector (<em>mail.domain.com &#8211; the FQDN public name of the On-Premises Exchange server</em>)</li>
<li>Address Scope &#8211;&nbsp;<em>tenant.mail.onmicrosoft.com</em></li>
<li>Smart Host &#8211; the MX provided by Microsoft Office 365 Domains DNS configuration (I.E.&nbsp;<em>domain-com.mail.protection.outlook.com</em>)</li>
<li>Source Server: The On-Premises Exchange server</li>
</ol>
</li>
</ol>
<p>Make sure to check any firewall rules that restrict WAN to LAN to port 25 to specific addresses.&nbsp; Use this list <a href="https://docs.microsoft.com/en-us/office365/enterprise/urls-and-ip-address-ranges">https://docs.microsoft.com/en-us/office365/enterprise/urls-and-ip-address-ranges</a> to set up your rules to lock down unauthorized access to Port 25 inbound.</p>
<table class="table">
<tbody>
<tr>
<td>10</td>
<td>Allow<br />
Required</td>
<td>Yes</td>
<td><code>*.mail.protection.outlook.com</code><br />
<code>40.92.0.0/15, 40.107.0.0/16, 52.100.0.0/14, 104.47.0.0/17, 2a01:111:f400::/48, 2a01:111:f403::/48</code></td>
<td><strong>TCP:</strong>&nbsp;25</td>
</tr>
</tbody>
</table>
<p>The post <a href="https://catastrophe.wiredwolf.com/office-365-hybrid-to-on-premises-exchange-mail-flow-how-to/">Office 365 Hybrid to On Premises Exchange &#8211; Mail Flow How-To</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Office 365 &#8211; Username Changes in AD affecting Azure AD &#8211; Attributes Locked</title>
		<link>https://catastrophe.wiredwolf.com/office-365-username-changes-in-ad-affecting-azure-ad-attributes-locked/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 08 Jan 2020 22:35:51 +0000</pubDate>
				<category><![CDATA[Microsoft Office 365]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Azure AD Connect]]></category>
		<category><![CDATA[immutableid]]></category>
		<category><![CDATA[Office 365]]></category>
		<category><![CDATA[proxyaddresses]]></category>
		<category><![CDATA[userprincipalname]]></category>
		<guid isPermaLink="false">https://catastrophe.wiredwolf.com/?p=18102</guid>

					<description><![CDATA[<p>I had a client who swapped usernames with another user.  The problems started showing up in Outlook where settings from the previous account-holder were showing up, described by both users as 'weirdness'. The problem was source anchors for the account was a direct link between the AD Object and the UPN in Office 365.  In  [...]</p>
<p>The post <a href="https://catastrophe.wiredwolf.com/office-365-username-changes-in-ad-affecting-azure-ad-attributes-locked/">Office 365 &#8211; Username Changes in AD affecting Azure AD &#8211; Attributes Locked</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I had a client who swapped usernames with another user.&nbsp; The problems started showing up in Outlook where settings from the previous account-holder were showing up, described by both users as &#8216;weirdness&#8217;.</p>
<p>The problem was source anchors for the account was a direct link between the AD Object and the UPN in Office 365.&nbsp; In AD the usernames were swapped, and TargetAddress, ProxyAddresses, etc., all updated, but when the synchronization to Office 365 happened the original tenant address (from a Hybrid Exchange Migration no doubt) was username@tenant.onmicrosoft.com, and it REFUSED to update.&nbsp; It showed as an alias in the online account, but was set as primary, and could not be removed.</p>
<p>Here&#8217;s the process to fix this:</p>
<ol>
<li>Remove the user(s) from the Synchronization and force a Delta sync<br />
Start-ADSyncSyncCycle -PolicyType delta</li>
<li>Recover the user from Deleted Users in Office 365 &#8211; this converts the account to Cloud status (no longer linked to AD)</li>
<li>Confirm the user is now showing up in Active Users as as a Cloud user</li>
<li>Obtain the objectGuid and userPrincipalName from AD using this command (in an elevated command window):<br />
ldifde -f C:\Export\export.txt -r &#8220;(Userprincipalname=*)&#8221; -l &#8220;objectGuid, userPrincipalName&#8221;</li>
<li>Locate the user account using the userPrincipalName and copy/paste the objectGuid and userPrincipalName to a new Notepad window</li>
<li>In an Elevated PowerShell window, log into the tenant<br />
Connect-MsolService&nbsp;</li>
<li>Now replace the ImmutableId of the converted Cloud user to match the one you pulled from AD:<br />
Set-MsolUser -UserPrincipalName &lt;userPrincipalName pulled from AD&gt; -ImmutableId &lt;objectGuid pulled from AD&gt;</li>
<li>Once the ImmutableID is updated you should update the Cloud user
<ol>
<li>In the Office 365 Admin go to Users &#8211;&gt; Active Users &#8211;&gt; User Name</li>
<li>In the User account fly-out &#8211; click on Manage email aliases</li>
<li>Remove the alias that was originally stuck and could not be removed</li>
</ol>
</li>
<li>Back in AD add the user back to the synchronization and perform an Initial Sync<br />
Start-ADSyncSyncCycle -PolicyType Initial</li>
<li>Wait for the synchronization to occur and refresh your Office 365 Active Users screen until the user account shows as being synchronized with AD</li>
</ol>
<p>The user will now be updated to reflect the values of Active Directory and accept future edits in Active Directory.</p>
<p>Outlook&#8217;s AutoDiscover should also pick up the changes and the &#8216;weirdness&#8217; reported should disappear.</p>
<p>NOTE: One thing I did find was the initial and following delta synchronizations did not actually update the user from Cloud to AD Synchronized status.&nbsp; However, making a minor modification to the account, such as adding an alias to proxyAddresses, did trigger the status change.&nbsp; Once changed, I just removed the extra alias and synchronized again.</p>
<p>NOTE: I also discovered that it can take a little while for minor changes to show up in the Office 365 console.&nbsp; It took over 5 minutes of refreshing the screen to get the offending source anchor alias I wanted to remove to even show up after the account was converted from AD to Cloud status.&nbsp; Just be patient.&nbsp; It will get there.&nbsp; Eventually.</p>
<p>The post <a href="https://catastrophe.wiredwolf.com/office-365-username-changes-in-ad-affecting-azure-ad-attributes-locked/">Office 365 &#8211; Username Changes in AD affecting Azure AD &#8211; Attributes Locked</a> appeared first on <a href="https://catastrophe.wiredwolf.com">Wiredwolf Canada</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
