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.

PowerShell

Extract various archives with PowerShell

Nowadays, instead of using .zip, .rar or .7z files, I find myself using virtual harddrives (.vhdx) more and more as it’s so much more convenient. However, extracting large amounts of compressed files, can be a very time consuming endeavor. Here a quick and dirty PowerShell script to do this. I’ve added a check for determining if the archive one folder in the root of the archive or if it contains multiple files and folders. If it contains just the one folder, the script won’t create a new folder and extract that one folder into the new folder. Instead it will “extract here”. If multiple files and/or folders are found, it will create a new folder based on the archive name. The script assumes you have 7zip installed on the default location.

Abandonware

Command & Conquer – Play in Dosbox

When Command & Conquer was released in 1995 and its companion with a different tone Command & Conquer: Red Alert in 1996, it was something of a revolution in the RTS game play. Of course Dune II had been released a few years before, also developed by Westwood studios, setting the tone for many RTS games that followed in the years to come. (This includes Warcraft, which eventually let to World of Warcraft, DOTA and many others that a lot of people still play daily nowadays)

Now that the remastered edition is announced for 2020, the 25th anniversary of the game, I got interested again in the original Dos game. Since the original is 2CD’s (GDI and NOD) and later an expansion was added named: Command & Conquer: The Covert Operations, I thought it was time to create a quick batch file to load which ever disk instead of having to type the commands in Dosbox every single time.
Batch files are the reason that I’m using non-standard commands and add-ons to Dosbox, so here the bat-file that I’ve written for C&C:

:menu
echo 1) C&C: GDI
echo 2) C&C: NOD
echo 3) C&C: Covert Operations
echo 4) Exit to Dos
choice /C:1234 /N Option:

if errorlevel = 1 goto GDI
if errorlevel = 2 goto NOD
if errorlevel = 3 goto COVERT
if errorlevel = 4 goto EXIT

:GDI
imgmount d “c:\temp\dosbox\e\cd\C&C\C&C-CD1.iso” “c:\temp\dosbox\e\cd\C&C\C&C-CD2.iso” “c:\temp\dosbox\e\cd\C&C\C&C-Cov.iso” -t cdrom
d:\C&C
goto menu

:NOD
imgmount d “c:\temp\dosbox\e\cd\C&C\C&C-CD2.iso” “c:\temp\dosbox\e\cd\C&C\C&C-CD1.iso” “c:\temp\dosbox\e\cd\C&C\C&C-Cov.iso” -t cdrom
d:\C&C
goto menu

:COVERT
imgmount d “c:\temp\dosbox\e\cd\C&C\C&C-Cov.iso” “c:\temp\dosbox\e\cd\C&C\C&C-CD1.iso” “c:\temp\dosbox\e\cd\C&C\C&C-CD2.iso” -t cdrom
d:\C&C
goto menu

:EXIT
exit

The CD’s can be cycled with CTRL-F4 if C&C asks for it.

Linux

Ubuntu displays print_req_error: I/O error, dev fd0, sector 0

With a new install as a virtual server, Ubuntu repeatedly displays the error:

print_req_error: I/O error, dev fd0, sector 0

The reason is the virtual server does not have a floppy drive. To resolve:

# sudo rmmod floppy
# echo “blacklist floppy” | tee /etc/modprobe.d/blacklist-floppy.conf
# sudo dpkg-reconfigure initramfs-tools

The message should now be gone for good.

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.

Windows 10

Windows 10: Set search results default to detail view

For some reason Microsoft seems to think that “Content” view for search results is the best view. This goes for “generic” folders in general, but me for content view is a view that I’d rather see go completely from Windows. Unfortunately I for me there is no easy setting to change this. This means it’s time to dive into the Windows Registry a little and set everything to use Details view as default.

Folder views are user specific, local and are controlled by the Windows Shell. This means the registry keys can be found under:

HKCU\SOFTWARE\Classes\Local Setting\Software\Microsoft\Windows\Shell

Here you should remove the keys BagMRU and Bags. Once these two are removed, add the following key:

HKEY_CURRENT_USER\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell{7fde1a1e-8b31-49a5-93b8-6be14cfa4943}

Create 2 DWORD values with:

“LogicalViewMode”=dword:00000001
“Mode”=dword:00000004

Now log off and log back on and every window should be set to Detail view.