Exchange Management Shell does not start (PowerShell vDir)

In the previous article I have already shown how to create new virtual directories for OWA, for example. However, the Exchange Management Shell was always used to recreate them. But what happens if the Exchange Management Shell no longer starts?

If the virtual directories need to be recreated and the Exchange Management Shell no longer starts, this article will help.

Exchange Management Shell does not start (PowerShell vDir)

A special feature is the virtual directory "PowerShell". This directory is used by the Exchange Management Shell to connect to Exchange. In the examples above, you can see that the Exchange Management Shell is always used to recreate the virtual directories. This is of course not possible if the Exchange Shell itself does not start.

In this example, I simply deleted both PowerShell directories in IIS to simulate an error:

PowerShell vDir

Deleting the PowerShell directory prevents the Exchange Shell from starting:

Exchange Management Shell

The error message of the shell shows the HTTP error code 403:

New-PSSession : [tex1.frankysweb.local] When connecting to the remote server "tex1.frankysweb.local" the following is displayed
Error occurred: The WinRM client has received an HTTP status code "403" from the remote WS-Management service. Further
Information can be found in the help topic "about_Remote_Troubleshooting".

If the Exchange Shell no longer starts, the directory can be recreated using the regular PowerShell. To do this, the normal Windows PowerShell must first be started with administrator rights. The Exchange SnapIn can then be added to the PowerShell with the following command:

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn

PowerShell

Since I "only" deleted the directories from the IIS, the PowerShell directories are still contained in the Exchange configuration. To recreate the deleted directories, the Exchange configuration must therefore also be cleaned up. The following two commands can be used for this:

Get-PowerShellVirtualDirectory -Server TEX1 | Remove-PowerShellVirtualDirectory
Get-PowerShellVirtualDirectory -Server TEX1 -ShowMailboxVirtualDirectories | Remove-PowerShellVirtualDirectory

PowerShell

The PowerShell directory for the front-end ("Default Web Site") can now be recreated with the following commands:

New-PowershellVirtualDirectory -Name "Powershell" -RequireSSL $false -CertificateAuthentication $true -BasicAuthentication $false -InternalUrl http://tex1.frankysweb.local/powershell

PowerShell

If only the front-end was defective, the Exchange Shell will now start again. If, as in my case, the back end is also defective/deleted, this must also be recreated.

Create new back-end

The PowerShell directory for the back-end can be created with the following command:

New-PowershellVirtualDirectory -Name "Powershell" -Role Mailbox -CertificateAuthentication $true -BasicAuthentication $false -WindowsAuthentication $true

PowerShell backend

If the creation of the back-end directory has worked, the next step can be skipped and the path can be corrected directly. If an error message appears, the next step must be carried out.

Optional: Clean up IIS Metabase

If the following error message appears when creating the back-end directory, you need to do a little more work:

New-PowershellVirtualDirectory : Error creating the virtual IIS directory
'IIS://TEX1.frankysweb.local/W3SVC/2/ROOT/Powershell' to 'TEX1'.
In line:1 Character:1
+ New-PowershellVirtualDirectory -Name "Powershell" -Role Mailbox -WebS ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (TEX1\Powershell (Exchange Back End):ADObjectId) [New-PowerShellVirtua
lDirectory], InvalidOperationException
+ FullyQualifiedErrorId : [Server=TEX1,RequestId=b2ccfa0d-722e-4ccb-92b6-7e2e5761f5b4,TimeStamp=17.10.2017 18:37:3
0] [FailureCategory=Cmdlet-InvalidOperationException] 5B396E6B,Microsoft.Exchange.Management.SystemConfigurationTa
sks.NewPowerShellVirtualDirectory

PowerShell backend

There are still residues in the IIS Metabase that need to be deleted first. The rather old tool "IIS Metabase Explorer" can be used to clean up the corpses in the IIS Metabase. The tool can be downloaded here:

The "IIS Metabase Explorer" requires .NET Framework 3.5 functions, which may have to be installed later:

.NET Framework Feature

In the IIS Metabase Explorer, the "PowerShell" entry must now be deleted under "LM -> W3SVC -> 2 -> ROOT":

IIS Metabase Explorer

Important: Pay attention to the 2 (marked blue). The front end is located under 1.

After the entry has been deleted, the virtual back-end directory can also be created again using the command as described above:

PowerShell

Now only the path needs to be corrected.

Correct PowerShell back-end path

For the PowerShell back-end, the path in the IIS Manager must be adjusted at the end; the path points to the wrong directory after the new setting.

The path can be corrected via IIS Manager, here too it is important not to get the "wrong" website, so make sure that "Exchange Back End" is selected as the website:

IIS Manager

"-Proxy" is now added to the physical path in the advanced settings of the directory:

IIS Manager

In my case, "-Proxy" is added to the path "D:\Exchange\ClientAccess\PowerShell" and now refers to "D:\Exchange\ClientAccess\PowerShell-Proxy".

Now the Exchange Management Shell starts again:

Exchange Management Shell

10 thoughts on “Exchange Management Shell startet nicht (PowerShell vDir)”

  1. Hallo,

    ich habe diesen Fehler in einem anderen Zusammenhang. Ich habe im IIS per „Einschränkungen für IP-Adressen und Domänen“ alle Virtuellen Verzeichnisse gesperrt und nur noch von dem lokalen Adressbereich zugreifbar gemacht. Für das virtuelle Verzeichnis „Powershell“ war das aber wohl zu viel des Guten. Auch das hinzufügen von 127.0.0.1 brachte keine Besserung. Nur wenn ich die Einsschränkung komplett aufhebe geht es wider. Kann das einer erklären?

    Reply
  2. Hallo zusammen,
    ich hab unseren Exchange 2016 CU16 auf CU19 upgegraded und bin genau in dieses Problem gelaufen.
    Die im Artikel vorgeschlagene Maßnahme hat nicht zum Erfolgt geführt.
    Virtuelle Verzeichnis ließen sich wie oben beschrieben ohne weiteres löschen und neu erstellen.
    Vielleicht weiß jemand Rat.

    Reply
  3. Hallo Franky,

    vielen Dank für die Anleitung. Bei mir scheint aber die web.config defekt zu sein in dem Ordner „PowerShell-Proxy“. Kann ich den auch einfach löschen und wird der dann inkl Config Datei neu erstellt?

    Falls das nicht geht, wie bekomme ich die Config Datei neu erstellt bzw. repariert?

    Danke!
    King Hundi

    Reply
  4. Seit dem letzten Update bekomme ich auf der Shell folgenden Fehler:
    Der WinRM-Client kann die Anforderung nicht verarbeiten. Der Inhaltstyp der HTTP-Antwort vom Zielcomputer kann nicht ermittelt werden.

    Wenn ich dann im Browser localhost/Powershell aufrufe gibt es folgenden Fehler:
    Die Datei oder Assembly „Microsoft.Exchange.Clients.Strings, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35“ oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.

    Debug:
    === Zustandsinformationen vor Bindung ===
    LOG: DisplayName = Microsoft.Exchange.Data.Directory, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    (Fully-specified)
    LOG: Appbase = file:///C:/Program Files/Microsoft/Exchange Server/V15/FrontEnd/HttpProxy/PowerShell/
    LOG: Ursprünglicher PrivatePath = C:\Program Files\Microsoft\Exchange Server\V15\FrontEnd\HttpProxy\PowerShell\bin
    Aufruf von Assembly : (Unknown).
    ===
    LOG: Diese Bindung startet im default-Load-Kontext.
    LOG: Die Anwendungskonfigurationsdatei wird verwendet: C:\Program Files\Microsoft\Exchange Server\V15\FrontEnd\HttpProxy\PowerShell\web.config
    LOG: Die Hostkonfigurationsdatei wird verwendet: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
    LOG: Die Computerkonfigurationsdatei von C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config wird verwendet.
    LOG: Verweis nach der Richtlinie: Microsoft.Exchange.Data.Directory, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    LOG: Download von neuem URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/powershell/788cbad3/5ed4f687/Microsoft.Exchange.Data.Directory.DLL.
    LOG: Download von neuem URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/powershell/788cbad3/5ed4f687/Microsoft.Exchange.Data.Directory/Microsoft.Exchange.Data.Directory.DLL.
    LOG: Download von neuem URL file:///C:/Program Files/Microsoft/Exchange Server/V15/FrontEnd/HttpProxy/PowerShell/bin/Microsoft.Exchange.Data.Directory.DLL.
    LOG: Download von neuem URL file:///C:/Program Files/Microsoft/Exchange Server/V15/FrontEnd/HttpProxy/PowerShell/bin/Microsoft.Exchange.Data.Directory/Microsoft.Exchange.Data.Directory.DLL.
    LOG: Download von neuem URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/powershell/788cbad3/5ed4f687/Microsoft.Exchange.Data.Directory.EXE.
    LOG: Download von neuem URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/powershell/788cbad3/5ed4f687/Microsoft.Exchange.Data.Directory/Microsoft.Exchange.Data.Directory.EXE.
    LOG: Download von neuem URL file:///C:/Program Files/Microsoft/Exchange Server/V15/FrontEnd/HttpProxy/PowerShell/bin/Microsoft.Exchange.Data.Directory.EXE.
    LOG: Download von neuem URL file:///C:/Program Files/Microsoft/Exchange Server/V15/FrontEnd/HttpProxy/PowerShell/bin/Microsoft.Exchange.Data.Directory/Microsoft.Exchange.Data.Directory.EXE.

    Reply
  5. Hallo Frank,

    Kann Leider trotz deiner sehr guten erklärung keine Virtuelle Powershelldirectory Erstellen wo kann es noch klemmen?

    Reply

Leave a Comment