Rename Windows Domain

The following procedure shows you how to rename an Active Directory domain.

  1. Open a command window in “administrator” mode and enter the following command which will generate a Domainlist.xml file:
rendom /list
  1. Edit the xml file, changing your old domain to the new one:
<?xml version ="1.0"?>
<Forest>
	<Domain>
		<!-- PartitionType:Application -->
		<Guid>210a7b30-fca4-486b-a660-b4ff8bdc5271</Guid>
		<DNSname>ForestDnsZones.kreider.io</DNSname>
		<NetBiosName></NetBiosName>
		<DcName></DcName>
	</Domain>
	<Domain>
		<!-- PartitionType:Application -->
		<Guid>8815a697-1a11-4a28-ab88-58e7ec1d5876</Guid>
		<DNSname>DomainDnsZones.kreider.io</DNSname>
		<NetBiosName></NetBiosName>
		<DcName></DcName>
	</Domain>
	<Domain>
		<!-- ForestRoot -->
		<Guid>61b2edc1-6431-251c-fac2-bebc218bcbea</Guid>
		<DNSname>kreider.io</DNSname>
		<NetBiosName>KREIDER</NetBiosName>
		<DcName></DcName>
	</Domain>
</Forest>

In the file, I modified kreider.local to kreider.io.

  1. Enter the following command to verify the match:
rendom /showforest
  1. Enter the following command to load the file:
rendom /upload
  1. Enter the following command which will allow you to contact all the domain controllers and prepare them for the change.
rendom /prepare
  1. Enter the following command to start the renaming. The controllers will restart automatically:
rendom /execute
  1. Enter the following to repair the GPO links:
gpfixup /olddns:kreider.local /newdns:kreider.io

Note: If you changed your NETBIOS name (up above in the XML file), you’ll need to run the following to update it. I didn’t in my particular situation.

gpfixup /oldnb:OLDNETBIOSNAME /newnb:NEWNETBIOSNAME
  1. The following command is to be passed when you are sure that all the stations have taken the name change into account because it removes the forwarders from the old name to the new one. I advise you to wait a few weeks especially if you have nomadic workstations.
rendom /clean

As a result of this, you will also be able to delete the old DNS zone from your server.

Reclaiming space from thin provisioned disks in VMware ESXi

This is the procedure that has worked for me. There are various methods dating as far back as 2011 across the internet, but this step-by-step works in my environment for Windows and Linux virtual machines.

Step 1 – Prepare the Guest Operating Systems

Windows

  • Download sdelete from Sysinternals (https://live.sysinternals.com/sdelete.exe)
  • In an elevated command prompt, run the following against the volume (in this example, C drive)
    • sdelete -z c:
  • Go to Step 2

Linux

  • For each volume you’ll want to run the following
    • dd if=/dev/zero of=/volume/zero.fill bs=1024k
  • After that completes, remove the zero.fill file from each volume.
    • rm /volume/zero.fill
  • To to Step 2

Step 2 – Punch some Holes

  • Shut down the virtual machine and power it off in vCenter or on the ESXi host
  • Log into the ESXi host via SSH
  • Navigate to the volume where the VM is stored
    • cd /vmfs/volumes/datastore/VirtualMachine
  • Punch the holes
    • vmkfstools -K VirtualMachine.vmdk
  • When completed, back in vCenter or the ESXi host web management, remove the VM from inventory (do not delete from disk). Use the following commands as root on the ESXi host also.
    • Unregister VM (More Info)
      • vim-cmd vmsvc/unregistervm vmid
        • You can get the vmid using vim-cmd vmsvc/getallvms
  • Add the VM back into inventory (go to the datastore and browse for where it is at; select the .vmx and click Register VM). Use the following commands as root on the ESXi host also.
    • Register VM (More Info)
      • vim-cmd solo/registervm /vmfs/volumes/datastore_name/VM_directory/VM_name.vmx

Improving Performance and Reliability of Windows Search

I usually hit Winkey and start typing whatever it is I’m looking to start; be it a command prompt, Outlook, explorer, or other installed applications and I rarely (read: never) use it for searching the internet.

Sometimes search gets “stuck”… because it’s crashing in the background. Here’s a method to improve performance and reliability of Windows 10 / Windows 11 Search by disabling search box suggestions.

reg add HKCU\Software\Policies\Microsoft\Windows\Explorer /v DisableSearchBoxSuggestions /d 1 /t REG

Bulk Delete Duplicate Files Using czkawkas Results File

czkawka tool to find duplicates works pretty well. I ran it against my NAS as I want to migrate data from that aging device to a new device and figured I would take the time to clean up many duplicate files. I have a previous post from the other day that details some of my journey with it so far and use against NAS devices.

The one thing I can’t figure out in czkawka is if there is an ability to, for each group of duplicates, delete everything but the first file listed in that group. What I’ve had to do is manually put checkmarks on the list. Fine and dandy for maybe a couple hundred duplicates, but I have about 15k duplicates in about 12k groups accounting for about 100GB of wasted space. That’s a LOT of clicking.

czkawka allows me to save a list of the duplicate files found. Here’s a sample structure of that results file.

-------------------------------------------------Files with same hashes-------------------------------------------------Found 14934 duplicated files which in 12706 groups which takes 96.99 GiB.

---- Size 1.76 GiB (1888739918) - 2 files
C:\nas_photography\1\IMG_7467.MOV
C:\nas_photography\1\New folder\DCIM\924BJHKG\IMG_7466.JPG

---- Size 748.34 MiB (784696092) - 2 files
C:\nas_photography\1\IMG_7524.MOV
C:\nas_photography\1\New folder\DCIM\924BJHKG\IMG_7523.JPG

---- Size 688.21 MiB (721643510) - 2 files
C:\nas_photography\1\IMG_7656.MOV
C:\nas_photography\1\New folder\DCIM\924BJHKG\IMG_7655.JPG

Here’s my attempt to “automate” this. I think I put about an hour of work into this (mostly fiddling with WSL trying to get the Windows share mount permissions working — which I didn’t get working).

#!/bin/bash

lineno=0
while IFS= read -r line
do
  if [[ "$line" =~ ^---- ]]; then
    lineno=1
  elif [[ "$line" =~ ^$ ]]; then
    lineno=0
  else
    ((lineno++))
    if [ "$lineno" -gt "2" ]; then
      echo del /q \""$line"\" >> windows_delete_duplicates.bat # For windows
      # echo rm -f \""$line"\" >> linux_delete_duplicates.sh # For linux
    fi
  fi
done < results_duplicates.txt

czkawka – Scan a NAS in Windows

I came across a nice tool named czkawka that “is a simple, fast and free app to remove unnecessary files from your computer.” I want to use this against an old NAS drive with tens of thousands of photos (and files) to find the duplicates and clean them up so I can move the 2TB of data to a different storage solution.

I couldn’t get the application to utilize the smb:// protocol as it suggests, for whatever reason (probably because I’m doing this in Windows). So here’s how I managed to give access to the application for my NAS share.

net use P: \\mediaserver\pictures
mklink /D C:\NAS_Pictures P:\
symbolic link created for C:\NAS_Pictures <<===>> P:\

Now in czkawka, I add the C:\NAS_Pictures source folder and begin to scan…