Hyper-V

Force Remove Host from SCVMM 2016/2019 & Hyper-V Console

To remove from SCVMM:

Open PowerShell with administrative credentials:

PS C:\> $Credential = Get-Credential
PS C:\> $VMHost = Get-SCVMHost -ComputerName “<Hostname of Server here>”
PS C:\> Remove-SCVMHost -VMHost $VMHost -Credential $Credential

The Get-Credential cmd-let will open a prompt in which you have to supply credentials with the rights to remove the host. In the second line you specify the server. This doesn’t have to be the FQDN, the Netbios name will do.
The last line actually removes the server. This may take a few minutes, depending if the server responds or not. If the server does not respond, PowerShell waits for a time-out.

To remove from a Hyper-V console:

Open PowerShell with administrative credentials:

PS C:\> Get-VM
PS C:\> Remove-VM -name [“VM Name Here”] -force

Use this to remove VMs that are in the state of SavedCritical. The “Get-VM” command will show a list of VMs registered on this Hyper-V server. The Saved-Critical VMs will list there too. Make sure the -force is added or it won’t do the trick. If your machine name has spaces, use the quotes (without the square brackets of course].

This was tested on Server 2016 and Server 2019. It’s also expected to work on later server releases.

Microsoft Server

Report on BlueScreen (BSOD) events and stop codes with PowerShell

A PowerShell script to report on all BlueScreen events and stop codes from the Windows Event Log on a specific server can be a useful tool for system administrators to troubleshoot and prevent future system crashes. This script will query the System Event log for events related to bug checks (BlueScreens) on a local server or a remote server.
Note: I wrote this to check for one server at a time. If requested, or if I have a future need, I may adapt it to query a list of servers and have the output written to a log file.