Re-Encode h264/x264 to h265 without noticeable quality loss with PowerShell and FFmpeg

Over the years I’ve gathered a lot of videos from various sources. Some of these are uncompressed and take up various gigabytes of space, each! Even though storage is getting cheaper, I don’t really want to spend €200,- (each) for 16TB spinning disks, so the answer is High Efficiency Video Coding, or HEVC/H265.
Do note that the statement above will not hold up for an uncompressed backup of a UHD Blu-ray disk. There is absolutely no way that a 50GB+ copy will have the same quality as an 1GB compressed file. The statement above is about downloaded x264 content like Youtube clips, Web-Rips, etc.

I put a PowerShell script together below to do the following: