Using $? And !$? in PowerShell

 

   This is very helpful when you need to validate the last operation if it has information (values), in other words, if the last command was successfully.
For example, I want to validate if a folder exists in my computer:
PS C:\> $Folder = Get-ChildItem -Path c:\temp
if($?)
{
    Write-Host “The folder Temp already exists” -ForegroundColor Yellow
}
else
{
    Write-Host “The folder Temp does not exists” -ForegroundColor Yellow
}
The folder Temp already exists
PS C:\> 
Let’s give it a try with a folder that doesn’t exist
PS C:\> $Folder = Get-ChildItem -Path c:\temp\NewOne
if($?)
{
    Write-Host “The folder Temp already exists” -ForegroundColor Yellow
}
else
{
    Write-Host “The folder Temp does not exists” -ForegroundColor Yellow
}
Get-ChildItem : Cannot find path ‘C:\temp\NewOne’ because it does not exist.
At line:1 char:11
+ $Folder = Get-ChildItem -Path c:\temp\NewOne
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\temp\NewOne:String) [Get-Chil
   dItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChi
   ldItemCommand
The folder Temp does not exists
PS C:\> 
Yo can use !$?also, just change the order in the if-else. I mean first the validation if the result will be false, it’s easier if we see this example:
PS C:\> $Folder = Get-ChildItem -Path c:\temp
if(!$?)
{
    Write-Host “The folder Temp does not exists” -ForegroundColor Yellow
}
else
{
    Write-Host “The folder Temp already exists” -ForegroundColor Yellow
}
The folder Temp already exists
PS C:\> 
Now let’s try with a folder that does not exist
PS C:\> $Folder = Get-ChildItem -Path c:\temp\NewOne
if(!$?)
{
    Write-Host “The folder Temp does not exists” -ForegroundColor Yellow
}
else
{
    Write-Host “The folder Temp already exists” -ForegroundColor Yellow
}
Get-ChildItem : Cannot find path ‘C:\temp\NewOne’ because it does not exist.
At line:1 char:11
+ $Folder = Get-ChildItem -Path c:\temp\NewOne
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\temp\NewOne:String) [Get-Chil
   dItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChi
   ldItemCommand
The folder Temp does not exists
PS C:\>
Thanks for reading

 

How to get the folders size in windows

   Sometimes when we have some space problems, we need to know what information ewe must delete. The first step is get the folders with more space in the disk.
   There is not a fast way to know that, worst-case scenario you have to go through all folders one by one and right click to see the size used on disk.
   Researching on internet I found some PowerShell scripts to get folders details like name and size, but taking information from different sources I have created a script and even when I don’t get any error it takes more than an hour to finish, this is not a good idea for desperate people like me…. ¯\_()_/¯
This is the script… Not sure if it works because after an hour running  without any error, it never finishes.
But as part of the research I found a very interesting site with a bunch of Microsoft tools, one of them is “Disk Usage”  a very fast and reliable tool
After download and unzip the tool, this is the result:
You can copy and paste the information in a spreadsheet and you will be able to see the information as follow:
Adding a column to convert the Size on Disc to MB

How to see Windows time settings

   The command W32tm /query /configuration works in all windows versions and its helpful when a server takes another timeserver and can be different from other servers or computers running an application or service and there is a time discrepancy.
   There are more tools and different parameters to use with that command but sometimes with /query /configuration are enough.  

for more details you can visit https://docs.microsoft.com/en-us/windows-server/networking/windows-time-service/windows-time-service-tools-and-settings

How to connect powershell to Skype for business online

To use all cmdlets for Skype, you must install the module, first download from Microsoft:

Click on the .exe file to install
Basically, is Next – Next – Finish
Once the module is installed, open your powershell as administrator.
To Create the session type these lines:
#only once
#Set-ExecutionPolicy RemoteSigned
$Cred = Get-Credential
$Session = New-CsOnlineSession -Credential$Cred
Import-PSSession $Session
NOTE: only the first time delete # in order to uncomment the second line to allow execute scripts. After that, you can comment this line again, is not needed the next time you execute this script to create the session.
Input the credentials to open the session
Once the session is established, the prompt will appear
And, you can type get-CsOnlineUser UserName and you will see all the user properties.

And that’s it. You can start using all cmdlets for Skype online.

Process to purge emails in office 365

   When an email with malicious content like virus, phising, spam, etc is coming to the company we need to delete those emails from the recipients Inboxes, sometimes in the companies, an employee send an email with incorrect or offensive content, this process applies as well.
Please follow this process:  

1. create the content. (based on https://docs.microsoft.com/en-us/office365/securitycompliance/content-search)             



Click on Content search
Create a new Search
Here we can put the conditions like sender, date range, subject, attachment, etc.
Click on save and run, its important input a name for this search.
In the open option, we can see all the searches saved
Once the search has finished, go to powershell and use the cmdlet New-ComplianceSearchAction
NOTE: to use the compliance module execute this script
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationNameMicrosoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/-Credential $UserCredential-Authentication Basic-AllowRedirection
Import-PSSession $Session -DisableNameChecking
You can validate the report and this task has been completed.

Problems to install Skype for business online powershell module in windows 10

When I was trying to install the Skype for business online I was getting different errors, the first was
“must have C++ Redistributable (x64) – 14.10.25008 installed as a Minimum Runtime.”
while I was trying to install the module.

If I tried to import the module appears the follow error:
“import-module : the specified module ‘skypeonlineconnector’ was not loaded because no valid module file was found in any module directory.” 
The solution is download the latest supported C++, you can find it here:
After install, reboot the computer and you will be able to install the skype for business module without any problems.

To connect to Skype online, type the follow lines

Import-Module SkypeOnlineConnector
$userCredential = Get-Credential
$sfbSession = New-CsOnlineSession -Credential $userCredential
Import-PSSession $sfbSession

and Listo!

to make sure that you have the module ready, you can type Get-CsOnlineUser Username, for example:

and you will see the properties for that user.

I hope it helps.

How to see privates emails in outlook

   Recently I had a problem where an user was not able to see the emails sent with sensitivity “Private”, the user was able to see these emails in outlook on the web, but in outlook app he only sees how the unread items was increasing, but he didn’t realize why..
Just to validate, the first step is verify if the user has permissions in the shared, folder.
For this, we can go to Admin Exchange Recipients Shared.
In this case, we have a shared mailbox called Marketing. To validate the permissions, go to full access and check if the user appears.

The user test user2 has full access permissions, then so far so good.
In order to solve the issue, go to outlook app in the user computer (No Outlook on the web)
Go to search in the user computer
You need to configure outlook with the shared mailbox settings, in this case Marketing.
NOTE: Could be easier if you reset the windows password, create a windows profile and open outlook, in automatic will be created its outlook profile.
Once the outlook profile has been configured for the shared mailbox.
Go to File menu – Account SettingsDelegates
Add the user who reports the issue, but the most important is check the option on “Delegates can see my privates items”
Close outlook and ask the users restart outlook and they will be able to see the emails.

How to import group policy module in powershell

 

Even if you have the RSAT tools installed in your computer, the Group policy module is not working. If you type a command like get-gpo –all –domain MyDomain.com you will receive an error like this:
get-gpo : The term ‘get-gpo’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
To fix this problem, go to start menu and search for optionalfeatures, as shown below:
Then, you will see Windows features window appear.
Expand Remote Server Administration Tools – Feature Administration tools and select Group Policy Management Tools:
Wait for the installation
Once the installation is done, go to Power Shell and import the module. Using Import-Module grouppolicy command
PS C:\> Import-Module grouppolicy
PS C:\> 
Now we have all GPO commandlets available
If you want to see all commands that belong for this module, type Get-Command –module grouppolicyand hit enter

Enjoy It.

 

How to install cumulative update for exchange 2016 and HealthyAndUpgrading status

Despite of we think the updates as patches, the Exchange 2016 cumulative updates are a complete installation of the messaging application. We can use this CU to install Exchange from scratch or update the Exchange organization.

As the media installation has all files to install a new exchange server, it means that you DON’T need to install the previous CU before install the latest version.

In this scenario, I am going to update from Exchange Cumulative Update 5 to CU 8. Please follow these steps.

• Download the media installation from Microsoft. Be careful; do not download the software from another site.
From Microsoft you will need Exchange CU 8 and .Net Framework 4.7.1.
Cumulative 8 does not implement changes into Active Directory, but CU 7. Therefore, when I execute CU 8 set up, it will make the same changes into Active Directory as CU 7.
• Search for known issues with this Cumulative Update, in some cases Microsoft detect issues with some updates releases and they publish a workaround or fixes to solve the issues. You need to be aware of these cases in order to determine if can be an impact in your organization, in some cases is better wait a little more while Microsoft release those fixes and you are confident to have a reliable version to install. Here you can see a justification to use always Microsoft site to download the installation media.
• Create backups. As the Active Directory will be affected by this installation, you need to have a reliable backup and obviously a backup for all Exchange data bases, in case that you have a DAG (Database Availability Group) configured, you need to check the copy(ies) status. 
• The best scenario, is install the Cumulative Update 8 in a test environment before go to production, with this approach you can detect any issue and work proactively solving any inconvenient before install the CU8 in your production servers.
• Document any customization you have made in production, for example sometimes we modify the ecp access, this changes are saved in web.config file located at C:\Program Files\Microsoft\Exchange Server\V15\ClientAccess, if this the case save a copy of the file. Note: DO NOT replace the file; just copy the code where you made the changes.
• Verify your Exchanges certificates are not expired. This is important to avoid loss access to servers and services.
• Verify that you have access to OWA (Outlook Web App) and you can read, send and receive emails, access to shared mailbox (if any), delegates, etc and create a checklist. After the installation, you will check all of these items again to validate that everything is working as expected.

Installing the Cumulative Update 8 

At this point you need to be aware of you will have some servers in a new version (CU 8) and others in the current version (Before CU8, in this scenario CU5). It’s Ok, this scenario is considered by Microsoft and everything is working properly, but you need to plan complete all the servers in a reasonable time (Maximum a couple of weeks).

If you have a DAG configured, you will put the server in maintenance mode and it helps to work even on business hours because the databases are mounted in other servers.

In my scenario, I don’t have Edge servers but if you have this role in your environment, should be the first servers in deploy Exchange Cumulative Update 8.

The follow steps, should be executed as they appear in this document.


Perform Active Directory, Domain and Schema changes and updates, remember if you are updating from CU7 to CU8, there is no changes, even though is a process that always Exchange setup will verify. Otherwise, you will find errors like these:

 

Error:
The Mailbox server role isn’t installed on this computer.
Error:
The Mailbox server role isn’t installed on this computer.
Error:
The Active Directory schema isn’t up-to-date, and this user account isn’t a member of the ‘Schema Admins’ and/or ‘Enterprise Admins’ groups.
Error:
You must be a member of the ‘Organization Management’ role group or a member of the ‘Enterprise Admins’ group to continue.
Error:
You must use an account that’s a member of the Organization Management role group to install or upgrade the first Mailbox server role in the topology.
Error:
You must use an account that’s a member of the Organization Management role group to install the first Client Access server role in the topology.
Error:
You must use an account that’s a member of the Organization Management role group to install the first Client Access server role in the topology.
Error:
You must use an account that’s a member of the Organization Management role group to install or upgrade the first Mailbox server role in the topology.
Error:
You must use an account that’s a member of the Organization Management role group to install or upgrade the first Client Access server role in the topology.
Error:
You must use an account that’s a member of the Organization Management role group to install the first Mailbox server role in the topology.
Error:
Setup encountered a problem while validating the state of Active Directory: Exchange organization-level objects have not been created, and setup cannot create them because the local computer is not in the same domain and site as the schema master.  Run setup with the /prepareAD parameter on a computer in the domain root and site RootEU, and wait for replication to complete.  See the Exchange setup log for more information on this error.
Error:
The forest functional level of the current Active Directory forest is not Windows Server 2003 native or later. To install Exchange Server 2016, the forest functional level must be at least Windows Server 2003 native.
Error:
The Mailbox server role isn’t installed on this computer.
Error:
Either Active Directory doesn’t exist, or it can’t be contacted.
Updating Active Directory, Domain and Schema
 
For this scenario, you need to install Microsoft .NET Framework 4.7.1 in the same computer that you will execute the follow commands, do remember download the framework from the Microsoft official site.
 
Make sure that you have the correct permissions assigned (Enterprise Admins and Schema Admins permissions) to execute the follow commands:
 
NOTE: open a command prompt window with elevated permissions, DO NOT use powershell.
 
1.       setup.exe /PrepareSchema /IAcceptExchangeServerLicenseTerms
2.      setup.exe /PrepareAD /IAcceptExchangeServerLicenseTerms
3.      setup.exe /PrepareDomain /IAcceptExchangeServerLicenseTerms
 
When the Schema, Domain and Active Directory changes have been applied and you didn’t get any error message, then you are good to start with the installation process.
 
Installing Exchange Cumulative Update 8 on Exchange Server 2016
 
In you have a DAG configured, let’s put the server in maintenance mode.
 
Open an Exchange Management Shell window.

Move to exchange scripts folder. Write: cd $exscripts

 
Execute this script:

 

.\StartDagServerMaintenance.ps1 -serverName -OverRideMinimumTwoCopies:$true
NOTE: Even some authors suggest use other commands to put a server in maintenance mode, this is working for me.

Once you can see all databases with healthy status, I suggest as good practice reboot the server to drop all connections from other users and applications opened by other processes or users. 

 
 
 
After reboot, let’s open the installation media, and right click to run as administrator the Setup.exe file. In this way, the installation has begun.

 

The setup process will detect that Exchange is installed and will appears the Upgrade window

Click on Next
Accept the license agreement.

In my case, I got this error:

Error: Setup can’t continue with the upgrade because the PowerShell (40928) has open files.
Open task manager, go to processes or details and finish all PowerShell processes.
Click on Retry
And just sit back and watch the progress.
 
During this process if you try to do something remote via PowerShell, you will receive this error:
PS C:\> Get-MailboxDatabaseCopyStatus -Server MyServer
Creating a new session for implicit remoting of “Get-MailboxDatabaseCopyStatus” command…
New-PSSession : [MyServer] Connecting to remote server MyServer failed with the following error message :
The connection to the specified remote host was refused. Verify that the WS-Management service is running on
the remote host and configured to listen for requests on the correct port and HTTP URL. For more information,
see the about_Remote_Troubleshooting Help topic.
When step 17 finishes, then reboot the server.
As we put the server in maintenance mode, now we need to stop it.
Open an Exchange Management PowerShell.

Move to Exchange Scripts folder.

Run the follow command: .\StopDagServerMaintenance.ps1 –serverName
Wait until the Databases have the Mounted status.


Important Notes.

The “Microsoft Exchange Search Service is crawling the database.” Message error.
 
You will see the follow state in the Content Index: HealthyAndUpgrading

Calm down!!!, is not necessary an error!!!

Remember that we are migrating from Exchange CU5 to CU8, this is a normal process after the installation.

If you run the follow command you will be able to see more details:

Get-MailboxDatabaseCopyStatus | fl
ContentIndexState                       : HealthyAndUpgrading
ContentIndexErrorMessage                : The Microsoft Exchange Search Service is crawling the database.
In my case, I have to wait a couple of days to see the DB’s in healthy status again, but meanwhile they were mounted and working without any issues.
You can verify the progress running the follow command:

Get-MailboxDatabaseCopyStatus -Server MyServer | select name, status, contentindexstate, ContentIndexMailboxesToCrawl
Depending of your server’s capacity and number of mailboxes can be fast or take too long to finish.

 

if we see an error with the Index DB: 

 

 
ContentIndexState                       : Failed

 

ContentIndexErrorMessage                : An internal error occurred for the database or its index.
LastCopyAvailabilityCheckFailedID       : DatabaseCheckPassiveCopyTotalQueueLength
LastCopyAvailabilityCheckFailedErrorMsg : Database copy ‘DB001′ on server ‘MyServer’ has a total
                                          (copy plus replay) queue length of 32761 logs, which is higher than
                                          the maximum allowed queue length of 400.
Give more time and the status will change to HealthyAndUpgrading again.

 

In summary, the state HealthyAndUpgrading is not really an error and you need to wait a while to see the correct state for Content Index.

 

If you restart the Exchange Search service, will be all Databases with Failed status and maybe you will be scare about this.
If you already did it, again just sit tight and wait.
Regards – Cheers – phir melenge – Hasta luego

 

How to install cumulative update for exchange 2016

Despite of we think the updates as patches, the Exchange 2016 cumulative updates are a complete installation of the messaging application. We can use this CU to install Exchange from scratch or update the Exchange organization.

As the media installation has all files to install a new exchange server, it means that you DON’T need to install the previous CU before install the latest version.

In this scenario, I am going to update from Exchange Cumulative Update 5 to CU 8. Please follow these steps.

  • Download the media installation from Microsoft. Be careful; do not download the software from another site. From Microsoft, you will need Exchange CU 8 and .Net Framework 4.7.1.

Cumulative 8 does not implement changes into Active Directory, but CU 7. Therefore, when I execute CU 8 set up, it will make the same changes into Active Directory as CU 7.

  • Search for known issues with this Cumulative Update, in some cases Microsoft detect issues with some updates releases and they publish a workaround or fixes to solve the issues. You need to be aware of these cases in order to determine if can be an impact in your organization, in some cases is better wait a little more while Microsoft release those fixes and you are confident to have a reliable version to install. Here you can see a justification to use always Microsoft site to download the installation media.
  • Create backups. As the Active Directory will be affected by this installation, you need to have a reliable backup and obviously a backup for all Exchange data bases, in case that you have a DAG (Database Availability Group) configured, you need to check the copy(ies) status.
  • The best scenario, is install the Cumulative Update 8 in a test environment before go to production, with this approach you can detect any issue and work proactively solving any inconvenient before install the CU8 in your production servers.
  • Document any customization you have made in production, for example sometimes we modify the ecp access, this changes are saved in web.config file located at C:\Program Files\Microsoft\Exchange Server\V15\ClientAccess, if this the case save a copy of the file. Note: DO NOT replace the file; just copy the code where you made the changes.
  • Verify your Exchanges certificates are not expired. This is important to avoid loss access to servers and services.
  • Verify that you have access to OWA (Outlook Web App) and you can read, send and receive emails, access to shared mailbox (if any), delegates, etc and create a checklist. After the installation, you will check all of these items again to validate that everything is working as expected.

 

Installing the Cumulative Update 8

At this point you need to be aware of you will have some servers in a new version (CU 8) and others in the current version (Before CU8, in this scenario CU5). It’s Ok, this scenario is considered by Microsoft and everything is working properly, but you need to plan complete all the servers in a reasonable time (Maximum a couple of weeks).

If you have a DAG configured, you will put the server in maintenance mode and it helps to work even on business hours because the databases are mounted in other servers.

In my scenario, I don’t have Edge servers but if you have this role in your environment, should be the first servers in deploy Exchange Cumulative Update 8.

The follow steps, should be executed as they appear in this document.

Perform Active Directory, Domain and Schema changes and updates, remember if you are updating from CU7 to CU8, there are no changes, even though is a process that always Exchange setup will verify. Otherwise, you will find errors like these:

PreReqError

Error:

The Mailbox server role isn’t installed on this computer.

For more information, visit: http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.UnifiedMessagingRoleNotInstalled.aspx

 

Error:

The Mailbox server role isn’t installed on this computer.

For more information, visit: http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.BridgeheadRoleNotInstalled.aspx

 

Error:

The Active Directory schema isn’t up-to-date, and this user account isn’t a member of the ‘Schema Admins’ and/or ‘Enterprise Admins’ groups.

For more information, visit: http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.SchemaUpdateRequired.aspx

 

Error:

You must be a member of the ‘Organization Management’ role group or a member of the ‘Enterprise Admins’ group to continue.

For more information, visit: http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.GlobalServerInstall.aspx

 

Error:

You must use an account that’s a member of the Organization Management role group to install or upgrade the first Mailbox server role in the topology.

For more information, visit: http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.DelegatedBridgeheadFirstInstall.aspx

 

Error:

You must use an account that’s a member of the Organization Management role group to install the first Client Access server role in the topology.

For more information, visit: http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.DelegatedCafeFirstInstall.aspx

 

Error:

You must use an account that’s a member of the Organization Management role group to install the first Client Access server role in the topology.

For more information, visit: http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.DelegatedFrontendTransportFirstInstall.aspx

 

Error:

You must use an account that’s a member of the Organization Management role group to install or upgrade the first Mailbox server role in the topology.

For more information, visit: http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.DelegatedMailboxFirstInstall.aspx

 

Error:

You must use an account that’s a member of the Organization Management role group to install or upgrade the first Client Access server role in the topology.

For more information, visit: http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.DelegatedClientAccessFirstInstall.aspx

 

Error:

You must use an account that’s a member of the Organization Management role group to install the first Mailbox server role in the topology.

For more information, visit: http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.DelegatedUnifiedMessagingFirstInstall.aspx

 

Error:

Setup encountered a problem while validating the state of Active Directory: Exchange organization-level objects have not been created, and setup cannot create them because the local computer is not in the same domain and site as the schema master.  Run setup with the /prepareAD parameter on a computer in the domain root and site RootEU, and wait for replication to complete.  See the Exchange setup log for more information on this error.

For more information, visit: http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.AdInitErrorRule.aspx

 

Error:

The forest functional level of the current Active Directory forest is not Windows Server 2003 native or later. To install Exchange Server 2016, the forest functional level must be at least Windows Server 2003 native.

For more information, visit: http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.ForestLevelNotWin2003Native.aspx

 

Error:

The Mailbox server role isn’t installed on this computer.

For more information, visit: http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.MailboxRoleNotInstalled.aspx

 

Error:

Either Active Directory doesn’t exist, or it can’t be contacted.

For more information, visit: http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.CannotAccessAD.aspx

 

Updating Active Directory, Domain and Schema

For this scenario, you need to install Microsoft .NET Framework 4.7.1 in the same computer that you will execute the follow commands, do remember download the framework from the Microsoft official site.

Make sure that you have the correct permissions assigned (Enterprise Admins and Schema Admins permissions) to execute the follow commands:

NOTE: open a command prompt window with elevated permissions, DO NOT use powershell.

  1. exe /PrepareSchema /IAcceptExchangeServerLicenseTerms
  2. exe /PrepareAD /IAcceptExchangeServerLicenseTerms
  3. exe /PrepareDomain /IAcceptExchangeServerLicenseTerms

When the Schema, Domain and Active Directory changes have been applied and you didn’t get any error message, then you are good to start with the installation process.

 

Installing Exchange Cumulative Update 8 on Exchange Server 2016

In you have a DAG configured, let’s put the server in maintenance mode.

Open an Exchange Management Shell window.

Move to exchange scripts folder. Write: cd $exscripts

ExScript

Execute this script:

.\StartDagServerMaintenance.ps1 -serverName <servername> -OverRideMinimumTwoCopies:$true

NOTE: Even when some authors suggest use other commands to put a server in maintenance mode, this is working for me.

Once you can see all databases with healthy status, I suggest as good practice reboot the server to drop all connections from other users and applications opened by other processes or users.

HealthyStatus

After reboot, let’s open the installation media, and right click to run as administrator the Setup.exe file. In this way, the installation has begun.

SetUp1

The setup process will detect that Exchange is installed and will appears the Upgrade window

Upgrade1

Click on Next

UpgradeLic

Accept the license agreement.

In my case, I got this error:

UpgradeErr1

Error: Setup can’t continue with the upgrade because the PowerShell (40928) has open files.

Open task manager, go to processes or details and finish all PowerShell processes.

Process

Click on Retry

Retry

And just sit back and watch the progress.

step1

During this process if you try to do something remote via PowerShell, you will receive this error:

 

PS C:\> Get-MailboxDatabaseCopyStatus -Server MyServer

Creating a new session for implicit remoting of “Get-MailboxDatabaseCopyStatus” command…

New-PSSession : [MyServer] Connecting to remote server MyServer failed with the following error message :

The connection to the specified remote host was refused. Verify that the WS-Management service is running on

the remote host and configured to listen for requests on the correct port and HTTP URL. For more information,

see the about_Remote_Troubleshooting Help topic.

 

When step 17 finishes, then reboot the server.

step17

As we put the server in maintenance mode, now we need to stop it.

Open an Exchange Management PowerShell.

Move to Exchange Scripts folder.  cd $exScripts

Run the follow command: .\StopDagServerMaintenance.ps1 –serverName <ServerName>

Wait until the Databases have the Mounted status.

 

Important Notes.

The “Microsoft Exchange Search Service is crawling the database.” Message error.

You will see the follow state in the Content Index: HealthyAndUpgrading

Calm down!!!, is not necessary an error!!!

Remember that we are migrating from Exchange CU5 to CU8, this is a normal process after the installation.

If you run the follow command you will be able to see more details:

Get-MailboxDatabaseCopyStatus | fl

 

ContentIndexState                       : HealthyAndUpgrading

ContentIndexErrorMessage                : The Microsoft Exchange Search Service is crawling the database.

 

In my case, I have to wait a couple of days to see the DB’s in healthy status again, but meanwhile they were mounted and working without any issues.

You can verify the progress running the follow command:

Get-MailboxDatabaseCopyStatus -Server MyServer | select name, status, contentindexstate, ContentIndexMailboxesToCrawl

Depending of your server’s capacity and number of mailboxes can be fast or take too long to finish.

ToCraw

if we see an error with the Index DB:

mountedFailed

ContentIndexState                       : Failed

ContentIndexErrorMessage                : An internal error occurred for the database or its index.

LastCopyAvailabilityCheckFailedID       : DatabaseCheckPassiveCopyTotalQueueLength

LastCopyAvailabilityCheckFailedErrorMsg : Database copy ‘DB001′ on server ‘MyServer’ has a total  (copy plus replay) queue length of 32761 logs, which is higher than                    the maximum allowed queue length of 400.

Give more time and the status will change to HealthyAndUpgrading again.

Mounted

In summary, the state HealthyAndUpgrading is not really an error and you need to wait a while to see the correct state for Content Index.

If you restart the Exchange Search service, will be all Databases with Failed status and maybe you will be scare about this.

If you already did it, again just sit tight and wait.

 

Regards – Cheers – phir melenge – Hasta luego