The trust relationship between this workstation and the primary domain failed

There are multiple reasons for getting this event. It mostly happen when you restore a domain joined server or workstation.
Event details:

EventID: 5719
Source: NETLOGON

This computer was not able to set up a secure session with a domain controller in domain “” due to the following:
There are currently no logon servers available to service the logon request. This may lead to authentication problems. Make sure that this computer is connected to the network. If the problem persists, please contact your domain administrator.

ADDITIONAL INFO
If this computer is a domain controller for the specified domain, it sets up the secure session to the primary domain controller emulator in the specified domain. Otherwise, this computer sets up the secure session to any domain controller in the specified domain.

There are multiple ways to fix this.
Just log in with your LOCAL (not domain) credentials.

1.The PowerShell way (yeah):

2. With netdom.exe using your Windows Command Prompt:

3. With the GUI:
Change your domain membership to WORKGROUP, reboot. And join again, reboot.

Kill a stopping service in Windows

Sometimes if you restart or stop a Windows service it wont stop. The Windows Service is stuck in the “stopping” state. If you cannot reboot your server or workstation for whatever reason you can kill the task using taskkill.exe.
First, open CMD (command prompt) as Administrator.
Then query the process ID (pid) using:

Look for the PID.
Then

Or using PowerShell with a force command:

How to move MSSQL Database to another drive

– Check which database is using the old drive. This can be done with the following query.

– Write down the output and check which DBs are placed on the old drive.
– Set your database offline with the following query:

– Move your physical DB files to your new location. Which given in the query above.
– Modify the following query to your database variables, and run it.

– Set your database online with the following query.

– Check with the first query if the replacement is successful.

Install git with PowerShell on Windows

With the following PowerShell function you can download and install git using PowerShell.

It downloads the latest “stable” git release to the given temp directory and installs it with default parameters.

Another and more easy way is using the package manager Chocolatey.
The Script:

Invoke-VMScript: An error occurred while sending the request

After upgrading the PowerShell module to the latest version now available (11.3.0.13964823), my invoke-vmscript goes wrong. The following exception occurs:

Finally after a couple hours of troubleshooting, parameter checking and reinstalls we found the issue. The issue is caused by a untrusted certificate of the VMWare VCenter server.

To solve this the “recommended” way: Check and fix your certificates on your system and VCenter server.
The dirty “not recommended” way: Add the following code to your script.

How to check the SFP state on a Physical Windows Host

In the past we have had an issue with a bad batch of  SFP’s in our Windows servers. The issue occurs randomly after a couple months in production.

The answer from HP about the bad SFP’s:
“The problem is due to the Manufacturing anomaly which has been corrected now .This issue causes early life degradation of Transmit (Tx) Power, causing the affected device to fail between 6-months and 1-year from first operation, depending on operational use. Affected SFP+ Short Wave Transceivers that begin to fail, first exhibit symptoms typical to Tx power degradation followed within weeks by symptoms typical to Tx power failure.”

They could not provide us more information about the affected serial / product numbers. Only way to check those SFPs is reading the operational status with a small tool.

Tool name: qaucli.exe
Which can downloaded from: Click here
Run the .exe to get the tool installed.

Check the Status. If the status not match “normal”, replace the SFP.

I automated the checks with a little not so fancy (I know) script.

NOTE: Only tested with QLOGIC adapters. Don’t know if this also work for the Emulex ones.
For Emulex refer this: For Emulex adapters use the Emulex® OneCommand® Manager Application to view the transceivers, their status and TX power level on the PortAttribute screen.

How to use credentials in a PowerShell script?

A nightmare for many security auditors are the plain tekst Passwords in PowerShell scripts. Offcourse this is not nessecary, we can encrypt this in local files.

But there is a difference how to encrypt passwords. Tou can encrypt it with your “user account key” or system wide with a “MachineKeyStore”.
The second one (machine key) is handy when you need to run scheduled PowerShell scripts under different user accounts.

Save plain text password with Machine Key encryption using PowerShell.

Save plain text password with User Key encryption using PowerShell.

HP ILO not Available and Reboot HP ILO With SSH

Sometimes you face the situation that your HP ILO is unresponsive. This mostly occurs when you need the ILO interface for a disaster (or something).

Now our good old friend SSH can help us, because this interface is mostly (slow) but still usable.

Open Putty.

Connect to your HP ILO Address.
Accept the certificate warning.

Then use the following 2 commands:
(this does NOT reset your ILO to default settings, it just reboots it)

How to install terraform on Windows

  1. Download Terraform
  2. Unzip Terraform to c:\Terraform
  3. Add terraform to your environment variables:

Test your installation typing terraform in CMD.
Your output should look like this:


A provider named “” could not be found in the Terraform Registry.

After installing Terraform and GO. I want to talk with my Hyper-v server for deploying some VMs.

I used this provider: https://github.com/taliesins/terraform-provider-hyperv.git

How to Install the Hyperv provider:

Now there is a file created: terraform-provider-hyperv.exe
After a terraform init you get the following message.

“A provider named “hyperv” could not be found in the Terraform Registry.”

This is because the custom provider is not installed in your default plugin directory.

The Windows default plugin directory is located in the following location: (C:\Users\YOURUSERNAME\AppData\Roaming\terraform.d\plugins\windows_amd64)

With PowerShell:

Copy the (terraform-provider-hyperv.exe) file you created with the go build in the plugin folder.

Now navigate to your cloned git directory \ examples \ basic and do a terraform init.