<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Harish Kaushal Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/harishck/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/harishck/feed.xml</link>
    <description>Office 365 Exchange Online and Identity Online Blog</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:21:46 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>PowerShell script to run MIM Delta or Full Sync</title>
      <link>https://docs.microsoft.com/archive/blogs/harishck/powershell-script-to-run-mim-delta-or-full-sync</link>
      <pubDate>Tue, 30 Jan 2018 10:36:10 GMT</pubDate>
      <dc:creator><![CDATA[Harish C Kaushal]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/harishck/?p=155</guid>
      <description><![CDATA[Hello Guys,
Struggling with finding out easy way to run MIM Delta or Full Sync, here is the script...]]></description>
      <content:encoded><![CDATA[<h5>Hello Guys,</h5>
Struggling with finding out easy way to run MIM Delta or Full Sync, here is the script which can help.
<ul>
 	<li>Run below command to create a directory to keep module.</li>
</ul>
<p style="padding-left: 30px">        <em>  New-Item -Path "$home\MimSync" -ItemType Directory</em></p>

<ul>
 	<li>Run below command to update PsModulePath</li>
</ul>
<p style="padding-left: 60px"><strong> </strong><em>$p = [Environment]::GetEnvironmentVariable('PSModulePath','User')</em></p>
<p style="padding-left: 60px"><em>$p += ";$home\"</em></p>
<p style="padding-left: 30px"><em>        [Environment]::SetEnvironmentVariable('PSModulePath',$p,'User')</em></p>

<ul>
 	<li>Extract the attached file to $home\MimSync folder.</li>
</ul>
<p style="padding-left: 60px"><strong>Link to Module</strong> : - <a href="https://msdnshared.blob.core.windows.net/media/2018/01/MimSync.zip">MimSync</a></p>

<ul>
 	<li>Run below commands to start sync.</li>
</ul>
<p style="padding-left: 30px">         <em>Import-Module MimSync</em></p>
<p style="padding-left: 30px"><em>         Start-MimSync</em></p>

<ul>
 	<li>You will get two options whether to run delta sync or Full sync.</li>
 	<li>Output will look like below.</li>
</ul>
<p style="padding-left: 60px"><img src="https://msdnshared.blob.core.windows.net/media/2018/01/Capture13.png" alt="" width="267" height="207" class="size-full wp-image-175 alignleft" /></p>
&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

Please do share feedback.]]></content:encoded>
    </item>
    <item>
      <title>Unable to remove domain from Office 365? Here is the script which can help!!</title>
      <link>https://docs.microsoft.com/archive/blogs/harishck/unable-to-remove-domain-from-office-365-here-is-the-script-which-can-help</link>
      <pubDate>Mon, 08 May 2017 12:32:09 GMT</pubDate>
      <dc:creator><![CDATA[Harish C Kaushal]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/harishck/?p=65</guid>
      <description><![CDATA[When we should use this script?
When you are trying to remove a domain from one Office 365 tenant...]]></description>
      <content:encoded><![CDATA[<h3><span style="text-decoration: underline"><em><strong>When we should use this script?</strong></em></span></h3>
When you are trying to remove a domain from one Office 365 tenant and want to verify domain on another tenant but you are unable to remove and getting errors like below.

<em>Remove-MsolDomain : Unable to remove this domain. Use Get-MsolUser -DomainName&lt;<span class="sbody-italic">domain name</span>&gt; to retrieve a list of objects that are blocking removal.</em>
<em>At line:1 char:18</em>
<em>+ Remove-MsolDomain &lt;&lt;&lt;&lt; -DomainName &lt;DomainName&gt;</em>
<em>+ CategoryInfo : OperationStopped: (:) [Remove-MsolDomain], MicrosoftOnlineException</em>
<em>+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.DomainNotEmptyException,Microsoft.Online.Administration.Automation.RemoveDomain</em>

<em>Remove-MsolDomain : Unable to complete this action. Try again later.</em>
<em>At line:1 char:1</em>
<em>+ Remove-MsolDomain -DomainName peppromotions.com –Force</em>
<em>+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</em>
<em>    + CategoryInfo          : OperationStopped: (:) [Remove-MsolDomain], MicrosoftOnlineException</em>
<em>    + FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.InternalServiceException,Microsoft.Online.Adm</em>
<em>   inistration.Automation.RemoveDomain</em>
<h3><span style="text-decoration: underline"><em><strong>What is the reason for these errors?</strong></em></span></h3>
We get this error when domain we are trying to remove is getting consumed in any of the Office 365 User or Exchange Recipient or Azure AD. So in order to release the domain first we need to remove all the references for that domain from Office 365, Exchange online and Azure.

So this script will help you in finding out where all domain is getting used.
<h3><em><span style="text-decoration: underline"><strong>What do you need to know before you begin?</strong></span></em></h3>
Need an admin account who is Global admin for Office 365, Exchange Online and Azure AD.

Windows PowerShell.

Azure AD and MSOnline modules installed.(Note: If not installed script will guide you in installing them)
<h3><strong><em><span style="text-decoration: underline">How to download?</span></em></strong></h3>
Download Link :- <a href="https://msdnshared.blob.core.windows.net/media/2017/05/Version-2.zip">version-2</a>
<h3><em><span style="text-decoration: underline"><strong>What all this script will do?</strong></span></em></h3>
Checks for all the modules required to perform steps in the steps and if they are missing it will guide to install.

Checks for domain references under users in Office 365 and extract CSV file.

Checks for domain references under recipients in Exchange Online and extract CSV file.

Checks for domain references in Azure AD and extract CSV file.

Helps in removing Azure Apps consuming the domain we want to remove.

If no references found then helps in removing domain.
<h3><em><span style="text-decoration: underline"><strong>How you can use it?</strong></span></em></h3>
<strong>1.</strong> Save attached and extract attached script. It should contain below files.

<a href="https://msdnshared.blob.core.windows.net/media/2017/05/Scripts1.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/05/Scripts1.png" alt="scripts" class="alignnone size-full wp-image-145" width="311" height="138" /></a>

<strong>2.</strong> Open windows PowerShell as administrator and run below command to set execution policy.

<em><strong>Set-ExecutionPolicy Unrestricted -Force</strong></em>

<strong>3.</strong> Run below command to set directory where script is extracted and import module.

<em><strong>cd "Directory where scripts extracted"</strong></em>

<em><strong>Import-Module .\DomainScriptModule.psm1</strong></em>

Once you run above command it will give you below warning four time as this script is not signed so you need to type "R" to allow this script.

<em>Security warning</em>
<em>Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your</em>
<em>computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning</em>
<em>message. Do you want to run D:\Scripts\DomainScript\DomainScript\DomainScriptModule.psm1?</em>
<em>[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): R</em>

<strong>4.</strong> Once you allow script it will start checking if AzureADPreview module is installed or not, if not it will give you an option to install as in my case its not installed so i selected Y in below option. It will perform same steps for MsOnline module and give you link if not installed.

<a href="https://blogs.msdn.microsoft.com/harishck/?attachment_id=95"><img src="https://msdnshared.blob.core.windows.net/media/2017/05/ModuleCheck.png" alt="modulecheck" class="alignnone size-full wp-image-95" width="1581" height="232" /></a>

<strong>5.</strong> In my case MsOnline module is also not installed so it will check and provide me an link to download module. Download module from listed link and re-import module.

<a href="https://blogs.msdn.microsoft.com/harishck/?attachment_id=96"><img src="https://msdnshared.blob.core.windows.net/media/2017/05/MsOnlineModule.png" alt="msonlinemodule" class="alignnone size-full wp-image-96" width="1579" height="97" /></a>

<strong>6. </strong>Once all module check passes it will import module and ask for Global admin credentials which is global admin for Office 365, Exchange online as well as Azure AD.

<a href="https://blogs.msdn.microsoft.com/harishck/?attachment_id=105"><img src="https://msdnshared.blob.core.windows.net/media/2017/05/Creds.png" alt="creds" class="alignnone wp-image-105" width="455" height="152" /></a>

<strong>7.</strong> After entering credentials it will connect to Office 365, Exchange online and Azure AD.

<strong>8.</strong> Once connected run below command.

<em><strong>Domain-RemovalScript</strong></em>

<strong>9.</strong> After executing above command it will ask for domain name which you want to remove. In my case i am typing abc123.com

<em><strong>Type domain you want to remove: abc123.com</strong></em>

<a href="https://blogs.msdn.microsoft.com/harishck/?attachment_id=115"><img src="https://msdnshared.blob.core.windows.net/media/2017/05/NoUserDomain.png" alt="nouserdomain" class="alignnone wp-image-115" width="535" height="133" /></a>

<strong>10.</strong> Once you type above command it will do below checks.

If domain exists on the tenant or not?If Yes, then continue otherwise Stop.

How many Msol users consuming domain?

How many Exchange Online users consuming domain?

How many Azure objects consuming domain?

If no reference found in any of the service then ask if you want to remove the domain or not.

<strong>11.</strong> In step 9, domain i used doesn't have any object reference so we get Green output and its asking if we want to remove the domain or not.

<strong>12.</strong> If i try domain which has object references in Office 365, Exchange and Azure output should look like below.

It will show you MSOL users which are consuming this domain.

It will ask for CSV file where you want to export the data of MsolUsers.

It will show you Exchange recipient and there type which all are consuming this domain and extract CSV.

It will show you Azure Apps which are consuming this domain and extract them to a CSV.

It will also give you option of you want to remove shown apps or not, if you select Yes, it will remove the apps.

<a href="https://blogs.msdn.microsoft.com/harishck/?attachment_id=125"><img src="https://msdnshared.blob.core.windows.net/media/2017/05/UserDomain.png" alt="userdomain" class="alignnone size-full wp-image-125" width="1573" height="1055" /></a>

<strong>13.</strong> Once you remove all the references run below command again to check and if all green, remove the domain.

<em><strong>Domain-RemovalScript</strong></em>

I hope it helps. Please do share your feedback in comments and it you run into any issues please feel free to share it in comments.

Thanks,

Harish]]></content:encoded>
    </item>
    <item>
      <title>Script to Update msExchArchiveGuid and msExchArchiveName in bulk from Exchange Online to On-premise AD</title>
      <link>https://docs.microsoft.com/archive/blogs/harishck/update-msexcharchiveguid-in-bulk-from-exchange-online-to-on-premise-ad</link>
      <pubDate>Sun, 26 Feb 2017 04:21:39 GMT</pubDate>
      <dc:creator><![CDATA[Harish C Kaushal]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/harishck/?p=35</guid>
      <description><![CDATA[Summary –

Use this script for errors like below on office 365 portal.

Failed to sync the...]]></description>
      <content:encoded><![CDATA[<strong>Summary –</strong>

Use this script for errors like below on office 365 portal.

<em><u>Failed to sync the ArchiveGuid 00000000-0000-0000-0000-000000000000 of mailbox 28b656595f-924b-4c5b-a4be-ea255450f  because one cloud archive 45e245ba67-a5ed-4408-8ced-a4d124521 exists</u></em>

Note: Recommended way to resolve this issue is using On-premise Exchange PowerShell. But these steps are for those scenarios wherein we don’t have on-premise exchange to fix this but exchange attributes are there in AD schema.

Managing the Exchange Attributes for cloud users from AD PowerShell or from ADSIedit is not supported and we strongly recommend keeping an active Exchange Server in your Active directory with minimum roles, just for being able to manage the Exchange attributes that shall be synced to the cloud.

For more information about these recommendations, you might find interesting below public article:

<a href="https://technet.microsoft.com/en-us/library/dn931280(v=exchg.150).aspx">https://technet.microsoft.com/en-us/library/dn931280(v=exchg.150).aspx</a>

<em>“The question of whether a third-party management tool or ADSIEDIT can be used is often asked. The answer is you can use them, but they are not supported. The Exchange Management Console, the Exchange Administration Center (EAC), and the Exchange Management Shell are the only supported tools that are available to manage Exchange recipients and objects. If you decide to use third-party management tools, it would be at your own risk. Third-party management tools often work fine, but Microsoft does not validate these tools. “</em>

<strong>Who should use this?</strong>

It can be used for users for whom you are getting error like below.

<em><u>Failed to sync the ArchiveGuid 00000000-0000-0000-0000-000000000000 of mailbox</u></em><u> 28b656595f-924b-4c5b-a4b</u><u>e-ea255450f</u><em><u>  because one cloud archive 45e245ba67-a5ed-4408-8ced-a4d124521 exists</u></em>

<strong>What do you need to know before you begin?</strong>
<ul>
 	<li>Should have installed MsOnline module for Office 365.</li>
 	<li>Should have Global admin credentials for Office 365.</li>
 	<li>Should have logged in to domain controller with Enterprise Admin credentials.</li>
 	<li>Should have rights to execute scripts.</li>
</ul>
<strong>How you do this?</strong>
<ol>
 	<li>Login to a domain controller which meets above per-requites.</li>
 	<li>Download and extract attached zip file in any location on the server. For example, I extracted it under “C:\O365”. There should be below 4 files.</li>
</ol>
&nbsp;

<em>ArchiveGuid_Version1.0.ps1</em>

<em>ArchiveGuid_Version1.0_Menifest.psd1</em>

<em>ArchiveGuid_Version1.0_Module.psm1</em>

<em>ConnectingToResources.ps1</em>

&nbsp;
<ol start="3">
 	<li>Open Windows PowerShell as administrator on the machine and set the directory of script files. For example, below.</li>
</ol>
&nbsp;

<em>Set-Location “C:\O365”</em>

&nbsp;
<ol start="4">
 	<li>Run below command and you should be able to see script files. If they are not there then you have set wrong location on step 3.</li>
</ol>
&nbsp;

<em>Get-ChildItem</em>
<ol start="5">
 	<li>Run below command to import module.</li>
</ol>
&nbsp;

<em>Import-Module .\ArchiveGuid_Version1.0_Menifest.psd1</em>

&nbsp;
<ol start="6">
 	<li>Run below command to connect to office 365 and when prompted enter Office 365 global admin credentials.</li>
</ol>
<em>ConnectTo-office365</em>
<ol start="7">
 	<li>Run below command to collect effected users data from Office 365.</li>
</ol>
<em>Get-EffectedMsolUser -CSVPath “location for csv file”</em>

<em><span style="text-decoration: underline">For example</span></em>:

Get-EffectedMsolUser -CSVPath "C:\O365\EffectedMsolUser.csv"

&nbsp;

**CSVPath – Path where you want to extract CSV file of effected MSOL users. Suggested to use same path where you have script files.

&nbsp;
<ol start="8">
 	<li>Run below command to collect effected mailboxes data from Office 365.</li>
</ol>
<em>Get-EffectedMailboxes -MsolUserCSVPath "location of CSV file collected in step 7" -MailboxCSVPath "location to create effected mailbox csv file"</em>

<span style="text-decoration: underline"><em>For example</em></span>:

Get-EffectedMailboxes -MsolUserCSVPath "C:\O365\EffectedMsolUser.csv" -MailboxCSVPath "C:\O365\EffectedMailboxes.csv"

&nbsp;

**MsolUserCSVPath – Path of CSV file collected in step 7.

**MailboxCSVPath – Location to create effected mailboxes csv. Suggested to use same path where you have script files.

&nbsp;
<ol start="9">
 	<li>Run below command to see effected AD accounts in your on-premise active directory. Output of this will show samAccountName of users where Archive Guid and name needs to be set.</li>
</ol>
&nbsp;

<em>Get-EffectedAdUser -EffectedMailboxCsvPath "location of CSV file generated in step 8" -EffectedPartition 'Domain partition where you want to search'</em>

&nbsp;

<span style="text-decoration: underline"><em>For example</em></span>:

Get-EffectedAdUser -EffectedMailboxCsvPath "C:\O365\EffectedMailboxes.csv" -EffectedPartition 'DC=hckoffice365,DC=in'

&nbsp;

**EffectedMailboxCsvPath – Location of CSV file generated in step 8. In my case its “C:\O365\EffectedMailboxes.csv”

**EffectedPartition (Not Mandatory) – Domain partition where you want to search and set the attributes. If you don’t mention this attribute, then script will take root partition by default.

&nbsp;
<ol start="10">
 	<li>Run below command to set Archive Guid and Archive Name values on effected user accounts.</li>
</ol>
&nbsp;

<em>Set-msExchArchiveInfo -EffectedMailboxCsvPath "location of CSV file generated in step 8" -EffectedPartition "domain partition where you want to set the values"</em>

&nbsp;

<em><span style="text-decoration: underline">For example</span></em>:

&nbsp;

Set-msExchArchiveInfo -EffectedMailboxCsvPath "C:\O365\EffectedMailboxes.csv" -EffectedPartition "DC=hckoffice365,DC=in"

&nbsp;

**EffectedMailboxCsvPath – Location of CSV file generated in step 8. In my case its “C:\O365\EffectedMailboxes.csv”

&nbsp;

**EffectedPartition (Not Mandatory) – Domain partition where you want to search and set the attributes. If you don’t mention this attribute, then script will take root partition by default.

&nbsp;
<ol start="11">
 	<li>Once above steps completed force directory sync from AAD connect server PowerShell using below command.</li>
</ol>
&nbsp;

<em>Start-AdSyncSyncCycle -PolicyType Initial</em>

&nbsp;
<ol start="12">
 	<li>Once sync completed check office 365 portal after 10-15 mins and there should not be any error for effected mailboxes. You can also confirm by performing step 7 again and this time output CSV file should be blank.</li>
</ol>
&nbsp;

<span style="text-decoration: underline"><strong>Script File Zip file</strong></span> - <a href="https://blogs.msdn.microsoft.com/harishck/2017/02/26/update-msexcharchiveguid-in-bulk-from-exchange-online-to-on-premise-ad/archiveguidscript/">Archive Guid Script</a>

&nbsp;

Please do share feedback in comments if you face any issues.

Thanks,

Harish Kaushal]]></content:encoded>
    </item>
  </channel>
</rss>