Tag: Service

HCSDiag.exe - Hyper-V Host Compute Service Diagnostics Tool

HCSDiag.exe – Hyper-V Host Compute Service Diagnostics Tool

As you know, Hyper-V is not just a server virtualization software anymore. Today, you can find Hyper-V technology across different operating systems, products, and services, like Windows Defender Application Guard, Windows Sandbox, Hyper-V Containers, or many more. Thanks to Ben Armstrong from the Hyper-V team, I found out that there is a tool in Windows to troubleshoot these Hyper-V containers called hcsdiag.exe or Hyper-V Host Compute Service Diagnostics Tool. The Hyper-V Host Compute Service Diagnostics Tool (HCSDiag.exe) is available in Windows 10 and Windows Server 2019 if you have the Hyper-V roles or virtualization features enabled, and can be helpful to troubleshoot Hyper-V containers, virtual machines (VMs), Windows Sandbox, Windows Defender Application Guard, Windows Subsystem for Linux 2 and more.

HCSDiag.exe - Hyper-V Host Compute Service Diagnostics Tool

HCSDiag.exe – Hyper-V Host Compute Service Diagnostics Tool

Let’s have a look at the HCSDiag.exe, which you can find in C:\Windows\System32. It provides you with a couple of different commands and options. However, keep in mind that not all features work with every type of container. Some features are limited to scenarios where the VM is being used under the same user context as the host, where it is all about protecting the host from the guest and not the guest from the host like in the server version of Hyper-V.

To install Hyper-V, check out the following posts:

HCSDiag.exe

hcsdiag <command> [options…]

  • list
    Lists running containers and VMs.
  • exec [-uvm] <id> <command line>
    Executes a process inside the container.
  • console [-uvm] <id> [command line]
    Launches an interactive console inside the container.
  • read [-uvm] <id> <container file> [host file]
    Reads a file from the container and outputs it to standard output or a file.
  • write [-uvm] <id> [host file] <container file>
    Writes from standard input or a host file to a file in the container.
  • kill <id>
    Terminates a running container.
  • share [-uvm] [-readonly] [-asuser] [-port <portnumber>] <id> <host folder> <container folder>
    Shares a host folder into the container.
  • vhd [-uvm] <id> <host vhdx file> <container folder>
    Shares a virtual hard disk file into the container.
  • crash <id>
    Forces a crash of the virtual machine hosting the container (only works for containers hosted in a virtual machine).

I will give you some examples of how you can use hcsdiag.exe to interact with some of the Hyper-V containers. Now again, this focuses mostly on technologies like Windows Sandbox, Docker Hyper-V Containers, WSL 2, and similar features.

You can find more documentation on Hyper-V on Windows Server or Hyper-V on Windows 10 on Microsoft Docs.

List all containers and Hyper-V VMs

With the hcsdiag list command, you can create a list of containers and Hyper-V virtual machines running on the host. Including Windows Sandbox, Windows Subsystem for Linux 2, and Application Guard.

hcsdiag.exe list

hcsdiag.exe list

Connect Console to Hyper-V containers and Windows Sandbox

You can also directly connect to the console of containers or the Windows Sandbox. Remember that it only works for Hyper-V containers where the guest is not protected from the host. Not for containers like Hyper-V VMs, where the guest is also protected from the host. If you need to remote into want console access or run commands against a Hyper-V VM from the host, check out PowerShell Direct for Windows VMs and hvc.exe for Linux VMs.

hcsdiag console connect

hcsdiag console connect

Here is an example where I am connected to a Windows Sandbox container using hcsdiag.exe.

hcsdiag Windows Sandbox

hcsdiag Windows Sandbox

But that also works with Dockers container (Hyper-V containers) running Windows and Linux.

hcsdiag Linux Container

hcsdiag Linux Container

HCSDiag console provides you with an interactive connection to interact with the container.

Additional HCSDiag.exe features and commands

The HCSDiag.exe also provides you with a couple of additional commands you can use. For example, the read command to read a file from the container and output it to the host or as a file to the host.

hcsdiag read

hcsdiag read

You can use the “share” command to share a host folder into the container or use “vhd” to mount a virtual disk file (VHD) file to a container. The hcsdiag kill command terminates a running container.

Conclusion

HCSDiag.exe – Hyper-V Host Compute Service Diagnostics Tool is excellent if you need to troubleshoot these Hyper-V containers, virtual machines (VMs), Windows Sandbox, Windows Defender Application Guard, Windows Subsystem for Linux 2 and more. If you have any questions, feel free to leave a comment.



VMware VirtualCenter Server service does not start automatically after reboot

We had a problem with our VMware VirtualCenter Server service which did not start automatically after a server reboot. This could be a problem when the VMware VirtualCenter Server service starts before the MSSQL Server.

Now the solution to solve this problem is to add a dependency to the VMware VirtualCenter Server service.

The VirtualCenter Server service is dependent on the following services:

  • SQL Services
  • ADAM Services (when using linked mode in vCenter Server 4.x)

How to create a service dependency:

  1. Open the services.msc
    services.msc
  2. Check out the name of the service you want to add as dependency
    sqlservice
  3. open the Registry Editor (regedit)
  4. Browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\vpxd
  5. Double-click the DependOnService key and add the Service name using the name of the Service in our case MSSQLSERVER
  6. In the Services window, open the service properties for the service VMware VirtualCenter Server.
  7. In the Dependencies tab, verify the VMware VirtualCenter service is listed as depending on the service.

In Windows Server 2008 or later you could also set VMware VirtualCenter Server service to startup type Automatic (Delay):

  1. Click Start > Run, type services.msc, and click OK.
  2. Right-click on the VMware VirtualCenter Server service and click Properties.
  3. Change the startup type from Automatic to Automatic (Delay).
    delaystartup

 
More Information on this: VMware KB



Install SNMP on Hyper-V R2 Core Server

Hyper-V

If your running Microsoft Hyper-V R2 or any Windows Server 2008 R2 Core Server you can install the SNMP Feature on the command line with the command line tool dism.

First you can list all Windows Features

Dism /online /get-features /format:table  

Now you can install for the SNMP Service:

Dism /online /enable-feature /featurename:SNMP-SC

SNMP Feature Core Server

After you have done this you and you have enabled Remote Management you can mange and configure smtp via remote MMC.

SNMP Service

Important: If you need to configure the SNMP Service on a remote machine you have to install the SNMP feature on the local administrative computer. Otherwise you will not see the SNMP specific tabs.

SNMP Service

More Information on installing Windows Features on a server running a Server Core installation of Windows Server 2008 R2: http://technet.microsoft.com/en-us/library/ee441253(WS.10).aspx



RsyncServer Service does not start on a Windows Server 2003

Today I got a error message from our monitoring that Rsync Service on one of our server doesn’t run. Reinstalling the service does not solve the problem. I could start the service but after some seconds the service stopped again.

The Event Log shows the following information:

==============================
Event Type: Information
Event Source: RsyncServer
Event Category: None
Event ID: 0
Date: 22.12.2009
Time: 08:30:52
User: WEB-WIN-xxx-xxx\SvcCWRSYNC
Computer: WEB-WIN-xxx-xxx
Description:
The description for Event ID ( 0 ) in Source ( RsyncServer ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: RsyncServer: PID 1856: `RsyncServer’ service stopped, exit status: 11.
==============================
There is a pretty easy solution for this problem:
  • Delete the .pid file in the cwrsync directory (in our case this is: C:\Program Files\ICW)
  • now start the service