Category: English

English version of my posts.

  • Fix Missing Network Adapter After Migrating VM to Hyper-V


    After migrating a virtual machine from another hypervisor (such as VMware or VirtualBox) to Hyper-V, you may notice that the network adapter is missing at the VM level.

    In some cases, the network adapter does not appear in Device Manager and is instead listed as an unknown device.
    When attempting to manually install the driver for the unknown device, you may encounter the error:

    The system cannot find the file specified

    Cause

    This issue typically occurs because the required driver file netvsc.sys is missing from the following directory:
    C:\Windows\INF

    Solution

    To resolve this issue, follow these steps:

    1. Navigate to: C:\Windows\System32\DriverStore\FileRepository
    2. Locate the folder containing the netvsc.sys file.
    3. Copy the file to: C:\Windows\INF
    4. Open Device Manager and reinstall the network adapter driver.

    After completing these steps, the network adapter should be detected and function correctly in Hyper-V.

    The log is located in C:\Windows\INF\setupapi.dev.log.

  • What is the time format in Bitbucket API?

    I was trying to retrieve a report in a Bitbucket instance. The return from the API contains event dates. However, the value looks strange. It is something like 1680143775227.

    The format looks like Unix Epoch Timestamp. But it was converted to a far future time in any online converters.

    The .Net action [System.DateTime]::UnixEpoch.AddSeconds() threw an error:

    MethodInvocationException: Exception calling "AddSeconds" with "1" argument(s): "Value to add was out of range. (Parameter 'value')"

    The solution is using [System.DateTime]::UnixEpoch.AddMilliSeconds() to convert the time.

    Such format calls Epoch Milliseconds or Unix Time in Milliseconds.

  • Fixing Motor Unresponsiveness on Raspberry Pi Due to Grounding

    The last time I wrote about Raspberry Pi was Connect to New Provisioned Raspberry Pi Less than $3, about six years ago. Time flies! Today, I will talk about a grounding issue.

    Background and Troubleshooting

    I recently purchased a powerful motor driver board. It supports two DC motors with encoders and other features. During the initial testing, I experienced weird behavior. As a cloud engineer, I find it interesting to learn about the physical world.

    (more…)
  • Terraform Cloud – How to List All Users

    Terraform Cloud – How to List All Users

    Terraform Cloud has a rich API. However, the API documentation does not mention how to list all users. We can leverage the organization membership API and the PowerShell command Invoke-RestMethod to get a user list.

    (more…)
  • Connect-NsxtServer shows “Unable to connect to the remote server”

    When you run Connect-NsxtServer in the PowerCLI, it may show “Unable to connect to the remote server“.

    Because the error message is a little bit confusing with other login issues. It’s not easy to troubleshoot. The actual reason is the NSX-T uses a self-signed certificate, and the PowerCLI cannot accept the certificate automatically.

    The fix is super easy. You need to set the PowerCLI to ignore the invalid certificate with the following command:

    Set-PowerCLIConfiguration -Scope User -InvalidCertificateAction:Ignore -Confirm:$false
  • Move Terraform Providers to Other Folders

    Create a new control file with the name .terraformrc or terraform.rc in your profile folder.

    Add the following lines:

    plugin_cache_dir   = "$HOME/.terraform.d/plugin-cache"

    Create the folder .terraform.d/plugin-cache in your profile folder.

    The providers will be downloaded to the cache folder when you run terraform init.


    If you don’t want to create the control file in the profile folder. Alternative is to create an environment variable.

    export TF_PLUGIN_CACHE_DIR="$HOME/.terraform.d/plugin-cache"
    
  • How to Use Proxy on WSL 2

    1. Install cntlm.
      sudo apt-get install cntlm
    2. Configure the permission for cntlm.conf file.
      sudo chmod 644 /etc/cntlm.conf
    3. Configure proxy settings.
      sudo vi /etc/cntlm.conf
    4. Make sure the following parameters are configured.
      Domain Domain
      Username username
      Proxy 1.2.3.4:5678
      NoProxy localhost, 127.0.0., 10.
      Listen 3128
    1. Test connectivity. (Hit enter key if it asks a password)
      cntlm -M http://www.google.com
    2. Generate hashed passwords.
      cntlm -H
    3. Paste the generated passwords to the cntlm configuration file.
    4. Configure proxy.
      export http_proxy=http://localhost:3128/
      export https_proxy=http://localhost:3128/
    5. Start cntlm
      sudo cntlm -v -c /etc/cntlm.conf

  • Setup Terraform and Ansible for Windows provisionon CentOS

    Setup Terraform and Ansible for Windows provisionon CentOS

    Provisioning Windows machines with Terraform is easy. Configuring Windows machines with Ansible is also not complex. However, it’s a little bit challenging to combine them. The following steps are some ideas about handling a Windows machine from provisioning to post configuration without modifying the winrm configuration on the guest operating system.

    1. Install required repos for yum.
    yum -y install https://repo.ius.io/ius-release-el7.rpm
    yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
    yum -y install epel-release
    yum -y install yum-utils
    yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
    ShellScript
    1. Install Terraform.
    sudo yum -y install terraform
    ShellScript
    1. Install Ansible.
    sudo yum -y install ansible
    ShellScript
    1. Install Kerberos.
    yum -y install gcc python-devel krb5-devel krb5-libs krb5-workstation
    ShellScript
    1. Install pip.
    sudo yum -y install python-pip
    
    # You probably need the following packages if you are using VPN
    pip install pysocks
    ShellScript
    1. Install pywinrm[kerberos].
    pip install pywinrm[kerberos]
    ShellScript
    1. Configure /etc/krb5.conf.
      The following are the required lines. Please make sure to change the domain name to yours. And it’s case-sensitive.
    [libdefaults]
     dns_lookup_realm = true
     dns_lookup_kdc = true
     forward = true
     forwardable = true
     default_realm = ZHENGWU.ORG
    
    
    [realms]
     ZHENGWU.ORG = {
      kdc = DC.ZHENGWU.ORG
      admin_server = DC.ZHENGWU.ORG
     }
    
    [domain_realm]
     .zhengwu.org = ZHENGWU.ORG
     zhengwu.org = ZHENGWU.ORG
    ShellScript
    1. Create an Ansible inventory file.
    [win] #Group name
    dc.zhengwu.org #This is the target server list
     
    
    [win:vars]
    ansible_connection=winrm 
    
    ansible_user=administrator #It's better a domain admin account.
    ansible_password=P@ssw0rd #Change this password
    ansible_port=5985
    ansible_winrm_transport=kerberos
    ansible_winrm_server_cert_validation=ignore
    ShellScript
    1. Run Ansible win_ping test.
    ansible <group in inventory file> -m win_ping -i <inventory file>
    ShellScript
  • Cannot log in to Microsoft Account over VPN

    Abstract

    I am using a VPN (proxy) to improve the access performance to global websites. There was a minor issue that I struggled with for a long time. I could not log in to any Microsoft account when using a VPN. The solution is to add the Your account to the loopback exemption. However, I’ll explain the reason in this post.

    Explanation

    Microsoft used a different way to run applications on Windows 8 and later versions. It is called AppContainers. This change leads to some applications not working with VPN (proxy) since it blocks some data exchanges between applications. The change is for security reasons. It basically isolates each application to block the communication on the local computer level.

    But, Microsoft offers a way to exempt applications for troubleshooting purposes. Hence, adding the applications to the exemption work around the problem.

    Following are some useful commands for exemption with Windows native commands:

    # Show a list of loopback exemption
    CheckNetIsolation.exe LoopbackExempt -s
    
    # Add an application to the exemption
    CheckNetIsolation.exe LoopbackExempt –a –n=<app name>
    

    It’s not easy to figure out the application name or ID. You should use Process Explorer. However, you can also download the 3rd party tool “Windows 8 AppContainer Loopback Utility” to configure it.

    AppContainer Loopback Exemption Utility
    Utility interface

    Reference

    How to enable loopback and troubleshoot network isolation (Windows Runtime apps) – Windows app development | Microsoft Docs

    AppContainers for Windows 8: What Are They and How Can You Create Them? | by Apriorit | Apriorit — Specialized Software Development Company | Medium

    AppContainer Isolation – Win32 apps | Microsoft Docs

    Allow an Application to bind and listen on a port to honor requests from outside the app (microsoft.com)

  • vSphere Web Client stuck on the loading screen

    vSphere Web Client stuck on the loading screen

    It’s been a while since my last post. I got an exciting issue a few days ago. I was trying to log in to a vCenter Server in Chrome. I can see the login screen and enter the credential. However, I was not able to get into the main page. vSphere Web Client was stuck on the “loading.”

    The reason is the Chrome version was 50. It’s incompatible with the vSphere Web Client version.

    Here are the vSphere Client requirements for your convenience.